text
stringlengths
8
4.13M
#![feature(type_alias_impl_trait, never_type, associated_type_bounds)] use http::StatusCode; use std::{ future::Future, net::SocketAddr, task::{Context, Poll}, }; use tower_service::Service; #[derive(Debug, Clone)] pub struct App; #[derive(Debug)] pub struct Connection { peer: SocketAddr, app: Ap...
use svm_sdk_mock::{template, Amount}; use svm_sdk_tests::{call_1, call_2}; #[template] mod Template { #[endpoint] fn add(a: Amount, b: Amount) -> Amount { a + b } #[endpoint] fn mul(a: svm_sdk::Amount, b: svm_sdk::Amount) -> Amount { a * b } #[endpoint] fn swap(a: Amo...
use num::FromPrimitive; enum_from_primitive!{ pub enum Instruction { INTEGER = 0x00, STRING = 0x01, ADD = 0x02, SHOWINTEGER = 0x0A, SHOWVERSION = 0x0E, EXITVM = 0x0F } } pub fn perin_version() -> f32{ 0.1 } pub struct PerinVM{ push: bool, stack: Vec<u8> } impl PerinVM{ pub fn new() -> PerinVM{ println...
/* * @lc app=leetcode id=516 lang=rust * * [516] Longest Palindromic Subsequence * * https://leetcode.com/problems/longest-palindromic-subsequence/description/ * * algorithms * Medium (47.87%) * Total Accepted: 72.1K * Total Submissions: 149.2K * Testcase Example: '"bbbab"' * * * Given a string s, fi...
#[doc = "Register `B5` reader"] pub struct R(crate::R<B5_SPEC>); impl core::ops::Deref for R { type Target = crate::R<B5_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<B5_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<B5_SPEC>) -> Se...
use crate::err::ParserError; use crate::err::ParserError::Expected; use crate::eval::object::Object; use crate::lexer::lexer::Lexer; use crate::lexer::token::{Token, TokenType}; use crate::parser::ast::*; use std::collections::{HashMap, HashSet}; pub type ParseResult<T> = Result<T, ParserError>; #[derive(PartialOrd, ...
use crate::readers::Index; #[derive(Debug, Clone)] pub enum Slice { Range(RangeSlice), Index(IndexSlice), } impl Slice { pub fn range(start: usize, end: Option<i64>, step: usize) -> Slice { Slice::Range(RangeSlice { start, end, step }) } pub fn index(idx: Index) -> Slice { Slice::Index(IndexSlice {...
fn main() { println!("972 multiplicated by 373638 is {}", multi(972, 373638)); } fn multi(first_number: i32, second_number: i32) -> i64 { let result: i64 = (first_number * second_number).into(); // to convert i32 to i64 result // without a semicolon, it's like `return result;` }
#[doc = "Register `CExINT` reader"] pub struct R(crate::R<CEXINT_SPEC>); impl core::ops::Deref for R { type Target = crate::R<CEXINT_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<CEXINT_SPEC>> for R { #[inline(always)] fn from(reader: crate::R...
use actions::AppAction; use redux::{DispatchFunc, Middleware, Store}; use std::sync::mpsc; use structs::app::events; use structs::app::{AppState, CommandHandler}; pub struct CommandMiddleWare { pub tx: mpsc::Sender<events::Event>, pub handler: CommandHandler, } impl Middleware<AppState> for CommandMiddleWare ...
mod connectivity; #[cfg(target_os = "windows")] mod handler; mod hotspot; mod platforms; /// Pre-requisite module for `Connectivity`, `Hotspot` functionality. pub mod prelude { pub use crate::connectivity::*; pub use crate::hotspot::*; pub use crate::platforms::Config; } pub use crate::platforms::WiFi;
use crate::parser::FIXED_COLUMNS; use std::{ fmt::{Display, Error, Formatter}, str::FromStr, }; /// A data line of the VCF file. #[derive(Debug, PartialEq)] pub struct DataLine { /// An identifier from the reference genome or an angle-bracketed ID String (“<ID>”) /// pointing to a contig in the assembl...
pub mod histogram; pub mod iter; pub mod encoding;
//! Show toggle controls using togglers. use std::hash::Hash; use iced_native::event; use iced_native::{ layout, mouse, row, text, Align, Clipboard, Element, Event, Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, }; /// A toggler widget #[allow(missing_debu...
use crate::net::{self, Message}; use std::sync::mpsc::{Sender}; use std::net::{SocketAddr}; pub trait Service { fn id(&self) -> u16; fn handle_message(&mut self, message: &mut Message) -> bool; } struct Network { id: u16, out: Sender<(Message, SocketAddr)> } impl Service for Network { fn id(&se...
pub mod polynomial; pub mod piecewise; pub mod calculus; pub mod function; pub mod interpolate;
use crate::coin_balance::HDAccountBalance; use crate::hd_pubkey::{HDExtractPubkeyError, HDXPubExtractor, RpcTaskXPubExtractor}; use crate::hd_wallet::NewAccountCreatingError; use crate::{lp_coinfind_or_err, BalanceError, CoinBalance, CoinFindError, CoinWithDerivationMethod, CoinsContext, MmCoinEnum, Unexpec...
pub mod wcwidth; pub mod grapheme;
use image as im; use piston_window; // use gfx_core; use gfx_device_gl; #[derive(Debug)] pub struct Buffer{ buf: im::ImageBuffer<im::Rgba<u8>,Vec<u8>> } impl Buffer{ pub fn new(x:u32, y:u32)-> Self{ Buffer{ buf: im::ImageBuffer::from_fn(x, y, |_, __| { im::Rgba([255,255,255,255]) }) ...
//对应代码清单2-29,切片类型示例 fn main(){ let arr: [i32;5] = [1,2,3,4,5]; assert_eq!(&arr,&[1,2,3,4,5]); assert_eq!(&arr[1..],[2,3,4,5]);//位置 //println!("{}",arr.len());//5 assert_eq!((&arr).len(),5); assert_eq!((&arr).is_empty(),false); let arr = &mut [1,2,3]; arr[1] = 7; assert_eq!(arr,&[1,7,...
use pegasus::preclude::{Filter, Map, Pipeline}; use pegasus::{Configuration, JobConf}; use std::time::Instant; use structopt::StructOpt; #[derive(Debug, Clone, StructOpt, Default)] pub struct Config { /// config size of each batch; #[structopt(short = "b", long = "batch", default_value = "1024")] batch_siz...
use serde::{Deserialize, Serialize}; pub mod badges_v1; pub mod new; pub mod v5; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Data<T> { pub data: T, } #[derive(Deserialize)] pub struct Chatters { #[serde(default)] pub broadcaster: Vec<String>, #[serde(default)] pub vips: Vec<String>...
#[cfg(test)] mod tests { use crate::controllers::handlers::get_file; use crate::controllers::tests::utils::utils; use crate::models::responses::ErrorResponse; #[test] fn get_file_missing_argument() { let req = rouille::Request::fake_http("GET", "localhost:1234", vec![], vec![]); let...
use std::io::prelude::*; use std::net::TcpStream; use std::net::TcpListener; // curl http://localhost:7878/ fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); for stream in listener.incoming() { let stream = stream.unwrap(); handle_connection(stream); } } fn handle_c...
//! [Ethereum Name Service](https://docs.ens.domains/) support //! Adapted from https://github.com/hhatto/rust-ens/blob/master/src/lib.rs use ethers_core::{ types::{Address, NameOrAddress, Selector, TransactionRequest, H160, H256}, utils::keccak256, }; /// ENS registry address (`0x00000000000C2E074eC69A0dFb299...
use postoffice::{server,resp,collector}; use json::JsonValue; use lazy_static::lazy_static; use std::sync::Mutex; mod path; mod collect; mod validate; mod engine; mod collections; mod io; struct BaseDir { path:String } impl BaseDir { fn overtake(self:&mut Self,path:String){ self.path = path; } } ...
use crate::errors::Error; use assert_matches::debug_assert_matches; use std::collections::{HashMap, HashSet}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct ID(pub(crate) usize); #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Kind { Module, Type, TypeMember, Func...
pub struct VolumeEnvelope { pub starting_volume: u8, pub add_mode: u8, pub period: u8, period_load: u8, pub current_volume: u8, period_counter: u8, } impl VolumeEnvelope { pub fn new() -> Self { VolumeEnvelope { starting_volume: 0, add_mode: 0, pe...
use std::default::Default; use rustc_serialize::{Encoder, Encodable, Decoder, Decodable}; #[derive(Debug, PartialEq, Clone)] pub enum Tag { File, Folder, } impl Encodable for Tag { fn encode<S: Encoder>(&self, encoder: &mut S) -> Result<(), S::Error> { encoder.emit_enum("Tag", |encoder| { ...
use crate::intcode::*; use std::collections::HashMap; use std::io::Write; #[derive(Debug, Clone, Copy, PartialEq)] enum BlockType { Wall, Block, Paddle, Ball, } use BlockType::*; impl BlockType { fn from(ty: i64) -> Self { match ty { 1 => Wall, 2 => Block, ...
#[doc = "Register `TEST` reader"] pub struct R(crate::R<TEST_SPEC>); impl core::ops::Deref for R { type Target = crate::R<TEST_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<TEST_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<TEST_SP...
use super::*; use crate::{Attributes, RTPWriter}; use anyhow::Result; use async_trait::async_trait; use rtp::extension::abs_send_time_extension::unix2ntp; use std::sync::Arc; use std::time::{Duration, SystemTime}; use tokio::sync::Mutex; struct SenderStreamInternal { ssrc: u32, clock_rate: f64, /// data ...
extern crate delaunator; extern crate serde_json; use delaunator::{triangulate, Point, Triangulation, EMPTY, EPSILON}; use std::f64; use std::fs::File; #[test] fn basic() { validate(&load_fixture("tests/fixtures/basic.json")); } #[test] fn js_issues() { validate(&load_fixture("tests/fixtures/issue11.json"));...
use super::req_ca::ask_ca_dec_keys; use super::req_ca::CA; use crate::common::myerror::{MyError, StrError}; use crate::common::tools::*; use crate::raft::ask::Snapshot; use crate::raft::config::Replier; use crate::sm::sm_impl_trait; use crate::sm::sm_impl_trait::Enctrait; use crate::trans::req_tls::MSG; use serde::{Des...
/// Return the Hamming distance between the strings, /// or None if the lengths are mismatched. pub fn hamming_distance(s1: &str, s2: &str) -> Option<usize> { if s1.len() != s2.len() { None } else { Some( s1 .chars() .zip(s2.chars()) .fold(0, |a, c...
use crate::{ draw_at, entry::{Entry, EntrySpaceLvl, EntryType, HiddenStatus}, ui::{ util::{get_style, Rect}, widgets::{VolumeWidgetBorder, Widget}, }, RSError, }; use std::{cmp::min, io::Write}; use pulse::volume; use crossterm::{cursor::MoveTo, execute}; impl<W: Write> Widget<W>...
use svm_sdk_mock::template; #[template] mod Template { #[storage] struct Storage { word: u16, words: [u16; 3], } } fn main() { // `word` let word = Storage::get_word(); assert_eq!(word, 0); Storage::set_word(0xABCD); let word = Storage::get_word(); assert_eq!(word,...
use crate::{IndividTrip, PersonID, PersonSpec, SpawnTrip, TripEndpoint, TripMode}; use geom::{Distance, FindClosest, LonLat, Pt2D, Time}; use map_model::Map; use serde::Deserialize; #[derive(Deserialize)] pub struct ExternalPerson { pub origin: LonLat, pub trips: Vec<ExternalTrip>, } #[derive(Deserialize)] pu...
use config::{ConfigError, Config, File}; use serde; use serde::de::Deserializer; use serde::Deserialize; pub trait DeserializeWith: Sized { fn deserialize_with<'de, D>(de: D) -> Result<Self, D::Error> where D: Deserializer<'de>; } #[derive(Debug, Deserialize, Clone)] pub enum ServerMode { Dev, Pr...
// //! Copyright 2020 Alibaba Group Holding Limited. //! //! 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 ...
//! A buffer of text organized into lines. Equipped with undo, redo, and anchors. //! //! Supports advanced language features, parsing, and many other useful features //! that enable speech coding. use crate::util::Oops; use std::collections::hash_map; use tree_sitter; use crate::language; use crate::util; use crate::...
extern crate serde; extern crate serde_json; #[macro_use] extern crate serde_derive; #[macro_use] extern crate log; extern crate futures; extern crate grpcio; extern crate protobuf; extern crate rayon; extern crate sem; mod common; mod common_map; mod common_reduce; pub mod service_proto; pub mod file_util; pub mod...
use std::collections::HashMap; fn main() { let mut p: HashMap<&str, HashMap<&str, i32>> = HashMap::new(); let (f, h): (Vec<(&str, &str, &str)>, Vec<(&str, &str, &str)>) = include_str!("input3").split("\n") .map(|l| { let mut a = l.split_whitespace(); (a.next().unwrap(), ...
use crate::ident::{Ident, Interner}; use lexpr::{datum, Number}; use lexpr::parse::Span; use lexpr::value::Value; // our own sexpr type which embeds the info we want pub struct Datum { node: Box<Node>, span: Span, } pub enum Node { Null, Num(Number), Symbol(Ident), Cons(Datum, Datum) } impl ...
#![feature(test)] extern crate test; use std::iter::Peekable; use std::io::{self, Read}; enum Operand { Next(usize), Prev(usize), Increment(u8), Decrement(u8), Print, Read, Loop(Vec<Operand>), } struct Machine { pointer: usize, memory: Vec<u8>, } impl Machine { const INITIAL_...
use super::super::super::core::cpu::ArmCpu; use super::super::super::device::audio::AudioDevice; use super::super::super::core::memory::*; use super::super::super::core::memory::ioreg::GbaChannel1; use super::get_freq_len_duty; use std; pub fn init(cpu: &mut ArmCpu, device: &AudioDevice) { let channel: &mut GbaChanne...
use crate::{ApiError, Context}; use beacon_chain::BeaconChainTypes; use eth2_libp2p::types::SyncState; use rest_types::{SyncingResponse, SyncingStatus}; use std::sync::Arc; use types::Slot; /// Returns a syncing status. pub fn syncing<T: BeaconChainTypes>(ctx: Arc<Context<T>>) -> Result<SyncingResponse, ApiError> { ...
use diesel::prelude::*; table! { users { id -> Integer, name -> Text, } } #[derive(Queryable)] struct User { name: String, id: i32, something_else: Vec<String>, } // rustc emits the following error message here: // ``` // error[E0277]: the trait bound `(String, i32, Vec<String>)...
pub mod api_actor; pub use api_actor::ApiActor;
/* * Copyright 2019 Comcast Cable Communications Management, LLC * * 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 applicab...
mod dev_cache; use std::fmt::Debug; use serde::{Deserialize, Serialize}; use super::*; pub use dev_cache::*; #[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] pub enum CacheEntry { Success(String), Failure(String), } pub trait Cache: Debug { fn save(&mut self, song: &SongDescriptor, entry: Cac...
use criterion::{criterion_group, BenchmarkId, Criterion}; const RANGE_OF_VALUES: [usize; 5] = [8, 10, 16, 20, 32]; use stabchain::group::stabchain::base::selectors::{FixedBaseSelector, LmpSelector}; use stabchain::group::Group; use std::iter::FromIterator; fn selector_comparison_cyclic(c: &mut Criterion) { let mut...
#![deny(unsafe_code)] use macaddr::MacAddr6; use std::fmt::Debug; use std::io; use std::iter; use std::net::{Ipv4Addr, SocketAddr, UdpSocket}; use structopt::StructOpt; const MAC_SIZE: usize = 6; const MAC_PER_MAGIC: usize = 16; const HEADER: [u8; 6] = [0xFF; 6]; const PACKET_SIZE: usize = HEADER.len() + MAC_PER_MAGIC...
use crate::{messages::Messages, object::Object}; use serde::{Deserialize, Serialize}; use tcod::colors::{DARK_RED, ORANGE, RED}; // combat-related properties and methods (monster, player, NPC). #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] pub struct Fighter { pub max_hp: i32, pub hp: i32, ...
use core::any::type_name; use shipyard::error; use shipyard::prelude::*; #[test] fn no_pack() { let world = World::new(); let (mut entities, mut u32s) = world.borrow::<(EntitiesMut, &mut u32)>(); entities.add_entity(&mut u32s, 0); entities.add_entity(&mut u32s, 1); entities.add_entity(&mut u32s, ...
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files // DO NOT EDIT #[cfg(any(feature = "v1_12", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))] use crate::TeamLinkWatcherArpPingFlags; #[cfg(any(feature = "v1_12", feature = "dox"))] #[cfg_attr(feature = "dox"...
use amethyst::{ assets::{Handle, Prefab}, core::{ math::{Vector2, Vector3}, Transform, WithNamed, }, ecs::prelude::World, prelude::{Builder, WorldExt}, renderer::{palette::Srgba, resources::Tint, transparent::Transparent}, }; use crate::{ components::{ Animation, Ani...
use std::collections::HashMap; use std::collections::LinkedList; use std::rc::Rc; use ast::*; pub enum LispDataType { Number(i32), String(String), BuiltInFunction(fn(&mut Environment, &[Syntax]) -> Rc<LispDataType>), Boolean(bool), Function(Vec<String>, Syntax), Void } pub type Scope = HashMap...
use std::ops::{BitOr, BitAnd}; use super::integer_casting::CastWithNegation; use super::interconnect::Interconnect; use super::opcode::*; use super::opcode::Op::*; use enum_primitive::FromPrimitive; #[derive(Copy, Clone, Debug)] pub struct CPUStatus { carry: bool, zero: bool, irq_disable: bool, decima...
#[doc = "Register `RAMON` reader"] pub struct R(crate::R<RAMON_SPEC>); impl core::ops::Deref for R { type Target = crate::R<RAMON_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<RAMON_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<RAM...
use std::io; use crate::wire_fmt::{HasWireType, WireType}; use super::reader::Reader; pub trait Deserialize: Default + HasWireType { fn merge(&mut self, reader: &mut Reader<impl io::Read>) -> io::Result<()>; fn deserialize(reader: &mut Reader<impl io::Read>) -> io::Result<Self> { let mut value = Sel...
use crate::intcode::*; pub fn run_a() { let data = std::fs::read_to_string("7.txt").expect("Unable to read file"); println!("7a: {}", determine_phases(&data, vec![0, 1, 2, 3, 4]).1); } pub fn run_b() { let data = std::fs::read_to_string("7.txt").expect("Unable to read file"); println!("7b: {}", determ...
fn main() -> Result<(), Box<dyn std::error::Error>> { let config = tonic_build::configure().out_dir("src"); config.compile(&["proto/say.proto"],&["proto/"])?; Ok(()) }
extern crate bytesize; use crate::{stream::Stream, tcp, udp, utils, utils::Command}; use std; use std::time; fn connect(protocol: &str, addr: &str, timeout: time::Duration) -> Result<Stream, String> { match protocol { "tcp" => Ok(tcp::connect(addr, timeout)?), "udp" => Ok(udp::connect(addr, timeou...
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Softwa...
//Anything related to PATCH requests for review app and it's properties goes here. use super::ReviewAppConfig; use crate::framework::endpoint::{HerokuEndpoint, Method}; /// Review App Configuration Update /// /// Update review app configuration for a pipeline /// /// [See Heroku documentation for more information abo...
use std::io::{self, BufRead}; type Result<T> = ::std::result::Result<T, Box<dyn ::std::error::Error>>; fn main() -> Result<()> { let mut input = String::new(); io::stdin().read_line(&mut input)?; part1(&input)?; part2(&input)?; Ok(()) } fn parse_opcode(i: i32) -> (i32, i32) { (i % 100, i / 10...
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // 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.a...
use crate::structures::{application::App, store::Store}; impl Store { pub fn new(apps: Vec<App>) -> Self { Self { apps } } }
use na::Vector3; use specs::prelude::*; pub const NEIGHBOUR_COUNT_2D: usize = 8; pub const NEIGHBOUR_COUNT_3D: usize = 26; const OFFSETS: [(i32, i32, i32); NEIGHBOUR_COUNT_2D] = [ (-1, -1, 0), (0, -1, 0), (1, -1, 0), (-1, 0, 0), (1, 0, 0), (-1, 1, 0), (0, 1, 0), (1, 1, 0), ]; const OF...
//! An attempt to collect several proposals of [rust-lang/wg-allocators](https://github.com/rust-lang/wg-allocators) into a //! MVP. //! //! Changes regarding the current `Alloc` trait //! ------------------------------------------- //! //! - The first thing to notice is, that [`Alloc`] was renamed to [`AllocRef`] in o...
#[allow(unused_imports)] use serde::{Serialize, Deserialize}; use std::sync::Arc; use ate::prelude::*; use rust_decimal::prelude::*; use names::Generator; #[derive(Debug, Serialize, Deserialize, Clone)] struct Person { first_name: String, last_name: String, } #[derive(Debug, Serialize, Deserialize, Clone)] st...
use modio::users::User; use serenity::builder::CreateEmbedAuthor; use serenity::framework::standard::CommandError; pub type CommandResult = Result<(), CommandError>; pub type EmbedField = (&'static str, String, bool); pub mod prelude { pub use std::fmt::Write; pub use futures::{Future, Stream}; pub use m...
pub mod host_mutation_resolvers; pub mod host_subscription_resolvers;
use crate::ast; use super::*; pub(super) async fn andor_list<'a>( ctx: &mut EvalContext, builtins: &Builtins, exec_sync: bool, show_result: &mut bool, list: &'a ast::AndOr<'a> ) -> i32 { let mut ret = 0; for (op, pipeline) in &list.pipelines { ret = exec_pipeline(ctx, builtins, ...
/* This file is part of bacon. * Copyright (c) Wyatt Campbell. * * See repository LICENSE for information. */ use super::polynomial::Polynomial; use nalgebra::ComplexField; mod spline; pub use spline::*; /// Create a Lagrange interpolating polynomial. /// /// Create an nth degree polynomial matching the n points...
mod ident; mod types; mod exprs; pub use ident::Ident; pub use types::Type; pub use exprs::{Expr, Literal, BinOp, ArithOp, ArithBinOp, CmpOp, CmpBinOp, If, Fun, LetFun, LetRec, Apply};
use util::units::{Offset, Point, Size}; #[derive(Clone, Copy, Debug, PartialEq)] pub struct Rectangle { location: Point, size: Size, } impl Rectangle { pub fn new(location: Point, size: Size) -> Rectangle { Rectangle { location: location, size: size, } } pu...
extern crate nom; use nom::*; use std::str; use std::collections::HashMap; use std::hash::Hash; #[derive(PartialEq,Debug)] pub enum JsonValue { Float(f64), Int(i64), String(String), Bool(bool), Object(HashMap<String, JsonValue>), Vec(Vec<JsonValue>), Null, } named!(quoted_str<&str>, ...
// Copyright 2020 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 ...
//! Code for parsing LLRP definitions from an XML file #[derive(Debug, serde::Deserialize)] #[serde(rename = "llrpdef")] pub struct LLRPDef { #[serde(rename = "$value")] pub definitions: Vec<Definition>, } #[derive(Debug, serde::Deserialize)] pub enum Definition { #[serde(rename = "messageDefinition")] ...
use std::fs::{create_dir_all, rename, OpenOptions}; use std::io::Write; use std::path::PathBuf; use failure::Error; use futures::Stream; use futures::prelude::Future; use futures::future::{ok, result}; use futures::stream::iter_ok; use hyper::{Body, Client, Uri}; use hyper::client::Connect; use slog::Logger; use std::...
extern crate log; extern crate env_logger; extern crate tor_controller; use tor_controller::utils; fn main() { env_logger::init(); println!("Tor Version = {:?}", utils::get_system_tor_version(None)); }
use failure::{format_err, Error}; pub fn pointer_to_rom_offset(data: &[u8]) -> Result<u32, Error> { assert!(data.len() >= 3); let value = ((data[0] as u32) << 13) | ((data[2] as u32 & 0x1f) << 8) | (data[1] as u32); if value < 0x40000 { Err(format_err!( "can't convert: {:02x} {:02x} {:...
use regex::Regex; use std::io::Write; use std::io; use std::process::exit; use std::iter::IntoIterator; use crate::codegen; use crate::codegen::{Codegen, IRBuilder, Module}; use crate::lexer::*; use crate::parser::*; use crate::util; use crate::target::write_asm_code; use llvm_sys_wrapper::{fn_type,LLVMFunctionType,LL...
use surf::Client; pub struct PvrService { client: Client, } impl PvrService { pub fn new(client: &Client) -> Self { Self { client: client.clone(), } } pub fn add_timer(&self) {} pub fn delete_timer(&self) {} pub fn get_broadcast_details(&self) {} pub fn get_broadcast_is_playable(&self)...
//Module to handle all channel related operations use hdk::{ error::ZomeApiResult, error::ZomeApiError, holochain_core_types::{ entry::Entry, cas::content::Address } }; use super::utils; use super::group; use super::user; use super::definitions::{ app_definitions, function_defi...
#[macro_use] extern crate render_gl_derive; pub mod buffer; pub mod data; pub mod shader; pub mod viewport; pub mod triangle; pub use self::shader::{Shader, Program, Error}; pub use self::viewport::Viewport; pub use self::triangle::Triangle;
pub const POLKADOT_GENESIS_HASH: &'static str = "0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"; #[derive(Clone, Eq, PartialEq, Debug)] pub enum Network { Polkadot, Unknow, } impl Default for Network { fn default() -> Self { Network::Polkadot } } impl From<&str> for Network { fn from(nam...
use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Clone, Serialize, Deserialize, Debug)] pub struct ConfigFile { pub groups: Vec<Group>, pub apps: Vec<App>, } #[derive(Clone, Debug)] pub struct OctoDepsState { pub groups: Vec<Group>, pub apps: Ve...
use cgmath::prelude::*; use cgmath::{Deg, Matrix4, PerspectiveFov, Point3, Vector3}; #[derive(Debug, Copy, Clone)] pub enum MovementDirection { Up, Down, Left, Right, } #[derive(Debug, Clone)] pub struct Camera { pos: Point3<f32>, front: Vector3<f32>, right: Vector3<f32>, up: Vector3<...
use std::collections::HashMap; pub struct Protein { pairs: HashMap<String, String> } impl Protein { pub fn name_for(&self, codon: &str) -> Result<&str, ()> { match self.pairs.get(codon) { Some(name) => Ok(name), _ => Err(()) } } pub fn of_rna(&self, sequence: &...
use std::os::raw::{c_char, c_void}; use wayland_sys::common::*; const NULLPTR: *const c_void = 0 as *const c_void; static mut types_null: [*const wl_interface; 4] = [ NULLPTR as *const wl_interface, NULLPTR as *const wl_interface, NULLPTR as *const wl_interface, NULLPTR as *const wl_interface, ]; static...
extern crate structopt; extern crate toml; #[macro_use] extern crate serde_derive; extern crate indexmap; extern crate rust_info; pub mod cargo_gen; pub mod cli; pub mod codegen; pub mod custom_config; pub mod file_packer;
//! Crate errors. use std::error::Error; use std::fmt; use std::io; /// Errors for the Arpabet crate. #[derive(Debug)] pub enum ArpabetError { /// The file or stream being read from was empty. EmptyFile, /// The file or stream contained invalid syntax. InvalidFormat { /// Line where the error occurred. ...
//! Heap layout generation. use super::TraceMap; use drone_config::size; use eyre::Result; use std::io::Write; const WORD_SIZE: u32 = 4; /// Generates a new empty layout for the given `size` and `pools`. pub fn empty(size: u32, pools: u32) -> Vec<(u32, u32)> { let pool_min = WORD_SIZE; let pool_max = size / ...
//! Utilities used by the Bittorrent Infrastructure Project. extern crate crypto; extern crate num; extern crate rand; extern crate chrono; /// Bittorrent specific types. pub mod bt; /// Arrays of buffers as a contiguous buffer. pub mod contiguous; /// Converting between data. pub mod convert; /// Networking primi...
extern crate serde_derive; use crate::{NumConversResult, SolanaCoin, SolanaFeeDetails, TransactionDetails, TransactionType}; use mm2_number::BigDecimal; use solana_sdk::native_token::lamports_to_sol; use std::convert::TryFrom; #[derive(Debug, Serialize, Deserialize)] pub struct SolanaConfirmedTransaction { slot: ...
// This is a test code to run benchmarks // based on basic example in examples/basic.rs // 1. Run prove() on b"sample" // 2. Run prove() on random bytes, length from 10 to 16384 // 3. Run verify() on proof of b"sample" #![feature(test)] extern crate test; use test::Bencher; use vrf::openssl::{CipherSuite, ECVRF}; use...
pub mod identifier_object; pub mod object; pub use identifier_object::ResourceIdentifierObject; pub use object::ResourceObject; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ResourceType { Ident...