text stringlengths 3.09k 13.9k |
|---|
// Copyright 2021, The Tremor Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed t... |
/// Abstraction which provides simple way to send RPC requests from a sync
/// context and check for available replies.
use std::convert::From;
use std::future::Future;
use std::pin::Pin;
use tokio::{
runtime::Handle,
sync::mpsc::{
channel,
error::{TryRecvError, TrySendError},
Receiver, ... |
//! Module capable of checking the onchain operations, such as
//! onchain `ChangePubKey` authorization or EIP1271 signature
//! verification.
use web3::{contract::Options, types::Address};
use zksync_contracts::eip1271_contract;
use zksync_eth_client::ethereum_gateway::EthereumGateway;
use zksync_types::{
tx::EIP... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use super::{
BaseElement, ElementDigest, ElementHasher, FieldElement, Hasher, Rp62_248, ALPHA, INV_ALPHA,
STATE_WIDTH,
};
use core... |
// Copyright 2017 PingCAP, Inc.
//
// 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 i... |
use crate::unicode::UnicodeIter;
use fontdue::{Font, FontSettings};
const NOTO_SANS_MONO_REGULAR: &[u8] = include_bytes!("res/NotoSansMono-Regular.ttf");
const NOTO_SANS_MONO_BOLD: &[u8] = include_bytes!("res/NotoSansMono-Bold.ttf");
const NOTO_SANS_MONO_LIGHT: &[u8] = include_bytes!("res/NotoSansMono-Light.ttf");
//... |
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
//! Common code that's shared across all migration code.
//! Each network upgrade / state migration code lives in their own module.
use address::Address;
use cid::Cid;
use clock::ChainEpoch;
use ipld_blockstore::BlockStore;
use state_tree... |
extern crate toml;
use std::env;
use std::path::{Path, PathBuf};
use std::fs::File;
use std::io::prelude::*;
use std::time::Duration;
use output::file::Config as FileConfig;
use output::stdout::Config as StdoutConfig;
#[derive(Deserialize)]
struct ConfigFromFile {
pub refresh_rate: Option<u64>,
pub pomodoro... |
extern crate bitvec;
extern crate clap;
extern crate num_cpus;
extern crate rayon;
use bitvec::prelude::*;
use rayon::prelude::*;
pub mod structs;
use std::cmp::Reverse;
use std::collections::{BTreeMap, BinaryHeap};
use structs::{ByteFreq, CompressedBits, CompressedBuffer, Info, Node, PqPiece};
pub fn compress(con... |
use crate::*;
pub struct OffsetScsiDevice<'a> {
device : scsi::scsi::ScsiBlockDevice<UsbClient<'a>, VecNewtype, VecNewtype, VecNewtype>,
block_buffer : VecNewtype,
partition_start : usize, //bytes
partition_idx : usize, //bytes from partition_start
loaded_block_number : usize,
needs_flush : ... |
// Copyright 2018 mondrian-schema-cat Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except ... |
use std::any::Any;
use std::collections::HashMap;
use parking_lot::RwLock;
use super::{scheduler, typed};
use crate::entity::ealloc;
use crate::system::spec;
use crate::util::DbgTypeId;
use crate::{comp, system, Global};
/// This type is used to build a world.
/// No more systems can be scheduled after the builder i... |
//! Tests for the wire format:
//!
//! - Encoder
//! -
//!
//! - Decoder
//! ✔ send everything at once
//! ✔ send data in small chunks, half the length, then the rest of the message in several parts.
//! ✔ randomly intersperse Pending...needs this functionality in futures_ringbuf.
//! - send incorrect data (e... |
/*******************************************************************************
* (c) 2021 Zondax GmbH
*
* 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/lic... |
use std::sync::{
atomic::{
AtomicUsize,
Ordering::{Acquire, Relaxed, Release},
},
Arc, Mutex,
};
use super::*;
pub(crate) struct Context {
// TODO file from config should be in here
config: Config,
pub(crate) pagecache:
PageCache<BLinkMaterializer, Frag, Recovery>,
... |
use crate::common::GreyscaleImage;
use hex_literal::hex;
use lazy_static::lazy_static;
use rusb::{Device, DeviceHandle, GlobalContext};
use std::time::Duration;
const OUT_ENDPOINT: u8 = 0x01;
const IN_ENDPOINT: u8 = 0x82;
pub const INIT_SEQUENCE: [&[u8]; 18] = [
&hex!("45 47 49 53 60 00 fc"),
&hex!("45 47 49 ... |
use std::marker::PhantomData;
use std::sync::Arc;
//use super::ResourceId;
use super::Dispatcher;
use super::RequiredResources;
// This holds the locks for resources that were acquired by the AcquireResources future
pub struct AcquiredResourcesLockGuards<T> {
_reads: Vec<tokio::sync::lock::LockGuard<()>>,
_w... |
/* -----------------------------------------------------------------------------------
* src/keyboard/win32_keysym_table.rs - Win32 key symbol table.
* beetle - Pull-based GUI framework.
* Copyright © 2020 not_a_seagull
*
* This project is licensed under either the Apache 2.0 license or the MIT license, at
* your... |
use super::Traversal;
use crate::traits::Storage;
use crate::types::VertexIterator;
use crate::V;
use std::collections::{HashMap, VecDeque};
use std::iter::FusedIterator;
use std::vec::Vec;
/// Depth-first search structure.
///
/// This structure contains the `discovery_time`, `finish_time` and `predecessor` maps.
///... |
#![cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
// This is an implementation of the extended arithmetic server from
// Vasconcelos-Gay-Ravara (2006) with some additional functionality
extern crate session_types;
use session_types::*;
use std::thread::spawn;
// Offers: Add, Negate, Sqrt, Eval
type Srv ... |
use futures::{
executor,
AsyncReadExt,
SinkExt,
StreamExt,
};
use rhymuri::Uri;
use rhymuweb::Response;
use rhymuweb_client::{
ConnectionUse,
HttpClient,
};
use std::{
cell::RefCell,
error::Error as _,
};
use structopt::StructOpt;
use websockets::{
WebSocket,
WebSocketClientBuild... |
use crate::builtin::std_format;
use crate::{equals, evaluate, Context, Val};
use crate::{error::Error::*, throw, Result};
use jrsonnet_parser::{BinaryOpType, LocExpr, UnaryOpType};
pub fn evaluate_unary_op(op: UnaryOpType, b: &Val) -> Result<Val> {
use UnaryOpType::*;
use Val::*;
Ok(match (op, b) {
(Not, Bool(v))... |
use crate::Video;
use anyhow::{anyhow, bail, Result};
use futures::{Stream, StreamExt, TryStreamExt};
use reqwest::header::{AUTHORIZATION, CONTENT_LENGTH};
use reqwest::{header, Body};
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use reqwest_retry::policies::ExponentialBackoff;
use reqwest_retry::Ret... |
use super::super::json;
use crate::{listener::Listeners, EventTypeFlags};
use std::{
convert::TryFrom,
error::Error,
fmt::{Display, Formatter, Result as FmtResult},
};
use twilight_model::gateway::event::{shard::Payload, Event};
#[derive(Debug)]
pub struct EmitJsonError {
kind: EmitJsonErrorType,
s... |
use super::base64_interface::Base64Interface;
use super::hex_interface::HexInterface;
use super::sdk_interface::SdkInterface;
use super::network_interface::NetworkInterface;
use super::query_interface::QueryInterface;
use crate::abi::{decode_message_body, Abi, ParamsOfDecodeMessageBody};
use crate::boc::{parse_message,... |
use crate::echo;
use crate::package::Package;
use crate::utils::Spinner;
use crate::Error;
use crate::Result;
use crossbeam_channel::{bounded, select, Receiver};
use crossbeam_utils::sync::WaitGroup;
use signal_hook::iterator::Signals;
use std::fs;
use std::io;
use std::process;
use std::sync::{Arc, Mutex};
use std::t... |
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
anyhow::Context,
bytes::Bytes,
futures::{future::ready, stream::once, AsyncReadExt, Stream},
serde::{Deserialize, Serialize},
std... |
use crate::event::{BlankNetwork, ErrorMessage, StateWrapper};
use crate::manager::{IdentityAddress, IdentityManager, NetworkAddress};
use futures::select_biased;
use futures::FutureExt;
use jsonrpc_core::Result;
use jsonrpc_derive::rpc;
use jsonrpc_pubsub::{
manager::{IdProvider, NumericIdProvider},
typed::Subs... |
use super::OUI;
use core::convert::TryInto;
use core::str::FromStr;
#[repr(transparent)]
#[derive(Default, PartialEq, Eq, Hash, Copy, Clone)]
pub struct EtherAddr(pub [u8; EtherAddr::SIZE]);
impl EtherAddr {
pub const SIZE: usize = 6;
pub const NULL: EtherAddr = EtherAddr([0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);... |
use clap::{App, Arg};
use find_similar_images::image_info::ImageInfo;
use find_similar_images::similarity::distance;
use find_similar_images::similarity::CalcHash;
use image;
use image::FilterType;
use itertools::Itertools;
use rayon::prelude::*;
use std::cmp::Reverse;
use std::collections::{BTreeSet, HashMap};
use std... |
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::{
container::ComponentIdentity,
events::{
error::EventError,
router::{Dispatcher, EventProducer},
types::*,
... |
use std::fs::File;
use std::hash::{Hash, Hasher};
use std::io;
use std::os::windows::io::{
AsRawHandle, IntoRawHandle, RawHandle,
};
use std::path::Path;
use winapi_util as winutil;
// For correctness, it is critical that both file handles remain open while
// their attributes are checked for equality. In particu... |
use std::{
fmt::Debug,
ops::{Add, BitAnd, BitOr, BitOrAssign},
};
use crate::math::{
cmp::{max, min},
simd::Float4,
vector2::Vec2,
};
use super::point::Point;
#[derive(Clone, Copy, PartialEq)]
pub struct Rect {
pub left: f32,
pub right: f32,
pub top: f32,
pub bottom: f32,
}
impl ... |
use dominator::{clone, events, html, Dom, DomBuilder};
use futures_signals::map_ref;
use futures_signals::signal::Mutable;
use futures_signals::signal_vec::MutableVec;
use futures_signals::signal_vec::SignalVecExt;
use wasm_bindgen::__rt::std::rc::Rc;
use web_sys::HtmlElement;
#[derive(Clone)]
pub struct NavigationEnt... |
mod utils;
use std::{convert::TryInto};
use wasm_bindgen::prelude::*;
extern crate seal;
use seal::pair::{
AlignmentSet, InMemoryAlignmentMatrix, NeedlemanWunsch, SmithWaterman, Step, Strategy,
};
#[wasm_bindgen]
extern {
fn alert(s: &str);
#[wasm_bindgen(js_namespace = console)]
fn log(a: &str);
}
... |
use bytes::Buf;
use serde::{Deserialize, Serialize};
use std::cmp::PartialEq;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Ruuvi3 {
data_format: u8,
humidity: Option<f32>,
temperature: Option<f32>,
pressure: Option<u32>,
acceleration_x: Op... |
use crate::config::Config;
use crate::Verbs;
use anyhow::{Context as AnyhowContext, Result};
use clap::crate_version;
use clap::ArgMatches;
use colored_json::write_colored_json;
use log::LevelFilter;
use reqwest::blocking::{Client, Response};
use reqwest::StatusCode;
use serde_json::{from_str, Value};
use std::fs;
use ... |
use thiserror::Error;
#[derive(Error, Debug, PartialEq)]
pub enum NesCartError {
#[error("Cannot read file: {0}")]
OpenFailure(String),
#[error("Invalid Magic")]
InvalidMagic,
#[error("Not enough header bytes")]
InvalidHeaderSize,
#[error("Unsupported ROM type")]
UnsupportedROM,
#[e... |
use crate::{
exec::interpreter::InstructionEnvironment,
model::{CallStackFrame, JavaValue, JavaValueVec, MethodDescriptor, RuntimeResult},
util::{get_constant_name_and_type, get_constant_string},
InvokeType,
};
use classfile_parser::constant_info::{ConstantInfo, MethodRefConstant};
fn create_stack_fram... |
pub mod macro_helpers;
pub mod process;
pub mod signature;
pub mod test;
use failure::Error;
use json5;
use serde::Deserialize;
use std::collections::HashMap;
use std::convert::TryInto;
use std::io::Read;
pub use memscanner_derive::{Scannable, ScannableEnum};
pub use signature::Signature;
macro_rules! read_type_impl... |
use std::default::default;
#[cfg(not(any(target_os = "ios", target_os = "android")))]
use glfw::{Action, Key};
use gm::Point;
use rapier2d::{
na::Vector2,
prelude::{
BroadPhase, CCDSolver, ColliderBuilder, ColliderSet, IntegrationParameters, IslandManager,
JointSet, NarrowPhase, PhysicsPipeline... |
use std::sync::Arc;
use aws_sdk_kinesis::error::{DescribeStreamError, PutRecordsError, PutRecordsErrorKind};
use aws_sdk_kinesis::types::SdkError;
use aws_sdk_kinesis::{Client as KinesisClient, Endpoint, Region};
use aws_smithy_async::rt::sleep::AsyncSleep;
use aws_smithy_client::erase::DynConnector;
use aws_smithy_ty... |
use std::default::Default;
use std::io;
use md5;
#[derive(Clone, Default, Debug)]
struct HashEntry {
start: u32,
end: u32,
modval: u32,
offset: u32,
and: bool,
}
/// A HashFeed is a list of hash matches.
#[derive(Default, Debug, Clone)]
pub struct HashFeed {
has_and: bool,
list: ... |
//! A library to provide Cross-site request forgery protection primitives.
//!
//! Getting this right can be tricky, and this library aims to provide the
//! primitives to be able to do this without making it too easy to get it
//! wrong. Remember though, this needs to be coupled with the HTTP layer
//! correctly as we... |
//! Aliasable `Vec`.
use core::ops::{Deref, DerefMut};
use core::pin::Pin;
use core::ptr::NonNull;
use core::{fmt, mem, slice};
pub use alloc::vec::Vec as UniqueVec;
/// Basic aliasable (non `core::ptr::Unique`) alternative to
/// [`alloc::vec::Vec`].
pub struct AliasableVec<T> {
ptr: NonNull<T>,
len: usize,... |
extern crate toml;
extern crate rand;
use std::fs::File;
use std::io::Read;
use std::io::Write;
use std::path::PathBuf;
use std::f64::consts::PI;
use std::ops::Neg;
use rand::Rng;
use rand::os::OsRng;
fn main()
{
let mut config_file_string = "spheregen.config.toml".to_string();
let mut args = std::env::args();
... |
extern crate nalgebra as na;
use na::Vector2;
use nphysics2d::algebra::Velocity2;
use nphysics2d::material::{MaterialHandle, BasicMaterial};
use ncollide2d::shape::{Cuboid, ShapeHandle};
use nphysics2d::object::{
ColliderHandle,
ColliderDesc,
};
use sdl2::event::Event;
use sdl2::keyboard::{Keycode, KeyboardSta... |
use std::borrow::{Borrow, BorrowMut};
use std::collections::HashMap;
use std::fmt;
use std::fmt::Display;
use std::hash::Hash;
use wasm_bindgen::JsValue;
use web_sys;
// Efficient append-only string builder for reducing reallocations
pub struct Appender {
i: usize,
buffers: Vec<String>,
}
impl Appender {
pub fn n... |
use super::identifiers::*;
use crc32fast::Hasher;
use log::info;
use rayon::prelude::*;
use std::fmt;
use std::fs;
use std::io::prelude::*;
use std::path::Path;
use MigrationResult::*;
#[derive(Eq, PartialEq)]
enum MigrationResult {
Migrated,
Updated,
Skipped,
}
#[derive(Default)]
pub struct MigrationResu... |
use std::{cell::Cell, collections::HashMap, rc::Rc};
use crate::{
converter::{Converter, IsoConverter},
plugin::Parameters,
range::Range,
type_cell::TypeCell,
};
#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ParameterIdTag;
pub type ParameterId = TypeCell<Par... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Provides support for rebooting the FPGA. You can select which of the four images to reboot to, just be sure to OR the image number with ``0xac``. For example, to reboot to the bootloader (image 0), write ``0xac``` to this register."]
... |
use crate::Waiter;
use arduino_uno::{
pac::EEPROM,
prelude::*,
};
use avr_hal_generic::port::mode::{
Input,
PullUp,
};
use micromath::F32Ext;
const PI: f32 = 3.1415926;
const MAG_ACC_ADDR: u8 = 0b0011101; // Magnetometer/accelerometer
const MAG_ACC_CTRL0: u8 = 0x1f;
const MAG_STATUS_REG: u8 = 0x07;
con... |
#![allow(dead_code)]
mod telnet;
mod web;
use std::{
borrow::Cow,
io::{self},
path::Path,
sync::atomic::{AtomicU16, Ordering},
time::Duration,
};
use once_cell::sync::Lazy;
use remud_lib::{run_remud, RemudError, WebOptions};
use tokio::time::timeout;
use tracing_subscriber::{
fmt::MakeWriter,... |
use crate::game::{physics::*, Point2d, *};
use gfx::input::*;
use ncollide2d::pipeline::CollisionGroups;
use rand::Rng;
use specs::prelude::*;
const MIN_MERCHANT_ARRIVAL_DAYS: i32 = 4;
const MAX_MERCHANT_ARRIVAL_DAYS: i32 = 7;
#[derive(Default)]
pub struct MerchantState {
has_arrived: bool,
next_arrival_day: ... |
use image::{self, DynamicImage, GenericImage, ImageResult, Rgba, RgbaImage};
use shape::Point;
use std::fmt;
use std::path::Path;
use std::sync::Arc;
pub fn rgba_to_str<T>(color: &Rgba<T>) -> String
where
T: fmt::Display + image::Primitive,
{
format!("{},{},{}", color.data[0], color.data[1], color.data[2])
... |
extern crate rand;
use std::env;
use rand::prelude::*;
use std::f64::consts::PI;
use std::io::{stdin, stdout, Write};
use std::process::Command;
macro_rules! block {
($xs:block) => {
loop { let _ = $xs; break; }
};
}
static HELP: &str = "Welcome to calc!\n================\n\nUsage:\n\n 'calc' opens ... |
// TODO: module-level docs
use std::any::{Any, TypeId};
use std::fmt;
/// This is the trait implemented by application events and event
/// families. Implementing this gives the necessary information to
/// allow `AnyEvent` conversions for this type.
///
///
/// For a struct type, a check is done for correspondence... |
use chain_crypto::digest::DigestOf;
use serde::Serialize;
use std::collections::{BTreeMap, BTreeSet};
use std::path::{Path, PathBuf};
use std::str::FromStr;
use super::Error;
use catalyst_toolbox::rewards::community_advisors::{
calculate_ca_rewards, ApprovedProposals, CommunityAdvisor, FundSetting, Funds,
Prop... |
use serde_json::Value;
use std::convert::TryFrom;
/// Enum representation of the 7 primitive types recognized by JSON Schema.
///
/// The usage of the enum allows to have a faster processing (less string comparisons)
/// as well as smaller memory footprint as the enum instance uses 2 bytes.
#[derive(Clone, Copy, Debug... |
//! Fetching code
use std::time::Duration;
use futures::{Future, Stream};
use futures::sync::mpsc;
use futures::future::{lazy, result, FutureResult};
use serde_json;
use tokio_timer;
use tokio;
use fetch_lib::https_client::{HttpsClient, FetchError};
use common::{asset, trade};
use super::KrakenFetchTargets;
use mode... |
#![doc = include_str!("../README.md")]
#![no_std]
use rasn::prelude::*;
use rasn_pkix::{
AlgorithmIdentifier, AuthorityInfoAccessSyntax, Certificate, CertificateSerialNumber,
CrlReason, Extensions, GeneralName, Name,
};
pub type Version = Integer;
pub type Nonce = OctetString;
pub type KeyHash = OctetString;... |
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::stats_scheduler::StatsRequest,
failure::bail,
fidl_fuchsia_wlan_mesh as fidl_mesh, fidl_fuchsia_wlan_mlme as fidl_mlme,
fidl_f... |
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at yo... |
use std::collections::HashMap;
use std::thread::sleep;
use std::time::Duration;
use simulator::{Environment, Event, Metrics, NetworkConfig, Node, Simulator, Timer};
use crate::example_metrics::DefaultMetrics;
use std::borrow::Cow;
mod example_metrics;
#[derive(Clone)]
pub enum PingPongEvent {
Init,
Ping(u8)... |
// https://github.com/gruberb/warp-examaple-api/blob/master/src/main.rs
// https://blog.logrocket.com/creating-a-rest-api-in-rust-with-warp/
use warp::{http, Filter};
use parking_lot::RwLock;
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::sync::Arc;
use serde::{Serialize, Deserialize};
use wa... |
use std::{
collections::{BTreeMap, HashMap, HashSet},
fs,
};
fn parse_line(line: &str) -> (Vec<&str>, Vec<&str>) {
let components: Vec<_> = line
.strip_suffix(")")
.unwrap()
.split(" (contains")
.collect();
assert_eq!(components.len(), 2);
let foods = components[0].... |
//! The Credentials provider from Cognito.
use async_trait::async_trait;
use rusoto_core::Region;
use rusoto_core::credential::{
AwsCredentials, CredentialsError, ProvideAwsCredentials, StaticProvider,
};
use crate::generated::{CognitoIdentity, CognitoIdentityClient, GetCredentialsForIdentityInput};
use chrono:... |
use rand::rngs::SmallRng;
use rand::Rng;
use rand_seeder::Seeder;
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use crate::config::GrammarSyntax;
use crate::modifier::Modifier;
/// By default, the grammar will be expanded starting from a symbol named `root`
const DEFAULT_ROOT_KEY: &str = "root"... |
pub trait Level {
fn size(&self) -> (usize, usize);
fn is_solved(&self) -> bool;
fn make_move<'a>(&'a mut self, x: usize, y: usize) -> &'a mut dyn Level;
fn get(&self, x: usize, y: usize) -> Option<usize>;
fn set(&mut self, x: usize, y: usize, v: usize) -> bool;
}
#[derive(Debug)]
pub struct Struct... |
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
//! Counts and verifies the number of reverie events received while the guest is busywaiting
//! o... |
use super::*;
/// Encodes an integer number to the integer representation defined by HPACK
/// based on the pseudocode provided by the HPACK specification ([5.1.]).
///
/// This is a generic function which is used in multiple places in the code
/// where a numeric value needs to be encoded into the HPACK format. The ... |
use godcoin::{
account::AccountId,
crypto::{KeyPair, PrivateKey, Wif},
serializer::*,
};
use rocksdb::{ColumnFamilyDescriptor, IteratorMode, Options, DB};
use sodiumoxide::{
crypto::{
pwhash::argon2id13,
secretbox::{self, gen_key, Key},
},
randombytes::randombytes_into,
};
use st... |
use crate::errors::*;
use crate::version::Version;
use bytes::*;
use std::cell::RefCell;
use std::mem;
use std::ops::{Add, Sub};
use std::rc::Rc;
pub const INT_8: u8 = 0xC8;
pub const INT_16: u8 = 0xC9;
pub const INT_32: u8 = 0xCA;
pub const INT_64: u8 = 0xCB;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct BoltInt... |
use std::cell::Ref;
use std::cell::RefCell;
use std::collections::LinkedList;
use std::error::Error;
use std::rc::Rc;
use std::{thread, time};
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::PixelFormatEnum;
use sdl2::rect::Rect;
use sdl2::render::Canvas;
use sdl2::surface::Surface;
use sdl2::vi... |
// Day 20: Trench Map
// https://adventofcode.com/2021/day/20
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use structopt::StructOpt;
/// parse command line arguments
#[derive(StructOpt)]
struct Cli {
#[structopt(default_value = "input.txt", parse(from_os_str))]
path: std::path::PathBu... |
//
// Copyright (c) 2019 Stegos AG
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, ... |
#![deny(missing_docs)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
//! This crate wraps the [blaze library](https://github.com/razer-rbi/blaze)
//! which is geared towards efficient and cross-platform 2D sprite drawing using OpenGL.
//! Supported features:
//! * Dynamic ... |
use std::collections::HashMap;
use crate::cli::{Command, EntityTypeEnum, InstallerTypeEnum};
use crate::error::Error;
use crate::filesystem::{
basename, create_directory, delete_repository_by_name,
delete_template_by_path, get_templates_directory,
get_repositories_map, get_templates_map, sanitize_path
};
u... |
use futures::channel::mpsc;
use std::collections::HashMap;
use std::io::BufRead;
use std::net::SocketAddr;
use std::str::FromStr;
use std::sync::Arc;
use tokio::net::TcpStream;
use tokio::prelude::*;
use crate::network::*;
use crate::paxos::*;
macro_rules! print_flushed {
($($tokens: tt)*) => {
{
... |
use crate::agent::Agent;
use crate::interpreter::Context;
use crate::intrinsics::promise::{new_promise_capability, promise_reaction_job, promise_resolve_i};
use crate::value::{ObjectKey, Value};
fn promise_proto_then(agent: &Agent, args: Vec<Value>, ctx: &Context) -> Result<Value, Value> {
let mut on_fulfilled = a... |
use nalgebra::base::{SMatrix, SVector};
pub type Matrix<const ROWS: usize, const COLS: usize> = SMatrix<f32, ROWS, COLS>;
pub type Vector<const ROWS: usize> = SVector<f32, ROWS>;
/// A simple Neuronal Network
///
/// + `N_INPUT` is the count of input variables
/// + `N_MAT` is the number of matrices transforming betw... |
use heck::SnakeCase;
use regex::Regex;
pub trait NamesChanger {
type Owned;
/// Convert a names of sql schemes from camelcase to snake case.
///
/// # Examples
///
/// ```
/// use names_changer::NamesChanger;
///
/// assert_eq!(&"TABLE ClientTokensRef IS 'text';".camel_to_snake(),
... |
use {
glium::glutin::{
self,
event::{Event as WinitEvent, WindowEvent},
event_loop::{ControlFlow, EventLoop},
},
reclutch::{
display::{
self, Color, DisplayListBuilder, DisplayText, FontInfo, GraphicsDisplay as _, Point,
ResourceData, ResourceDescripto... |
use std::mem::transmute;
use std::env;
use libc::{self, c_void, c_int, uintptr_t};
use perf_event_open::{Perf, EventSource, Event};
use crate::spin_lock::SpinLock;
use crate::opt;
type Context = *mut c_void;
type ReasonCode = c_int;
type Callback = extern "C" fn( Context, *mut c_void ) -> ReasonCode;
pub struct Back... |
use super::io::*;
use super::Error;
use anyhow::{anyhow, Result};
/// Represents a message that is sent from the server to the client.
#[derive(Debug)]
pub enum Message {
FramebufferUpdate(Vec<u8>),
SetColorMapEntries(Vec<u8>),
Bell(Vec<u8>),
ServerCutText(Vec<u8>),
// Extensions
EndOfContinu... |
use crate::format::RenderView;
use crate::object::Value;
use crate::prelude::*;
use ansi_term::Color;
use derive_new::new;
use prettytable::format::{FormatBuilder, LinePosition, LineSeparator};
use textwrap::fill;
use prettytable::{color, Attr, Cell, Row, Table};
#[derive(Debug, new)]
pub struct TableView {
heade... |
//!# Summary
//! Integrators are a major component in ray tracing as they compute the color of each pixel.
//! They come in various forms, taking different paths.
//!
//! # Notation
//! * `E` - The eye
//! * `L` - The light
//! * `D` - Diffuse reflection or transmission
//! * `G` - Glossy reflection or transmission
//!... |
use crate::alignments::{SAlignmentFunc, MAlignmentFunc};
use crate::models::*;
use crate::readers::{Index, Value, RAReader};
use crate::iterators::*;
use std::cmp::{min, max};
#[derive(Debug)]
pub struct AlignedDimension {
pub source_dim: usize,
pub source_start: usize,
pub source_step: usize,
pub target_dim:... |
use serde::Deserialize;
use crate::{
DateTime,
Utc,
Url,
};
use super::{
Account,
Application,
Attachment,
Card,
Emoji,
Entity,
Mention,
Poll,
Tag,
Visibility,
};
/// Represents a status posted by an account.
#[derive(Debug, Clone, Deserialize, mastors_derive::Entity... |
use serde::{Serialize,Deserialize};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum NameCase {
SnakeCase,
ScreamingSnakeCase,
UpperCamelCase,
LowerCamelCase,
Fixed
}
#[derive(Constructor, Clone, Getters, CopyGetters, Setters, Debug, PartialEq, Eq, Hash, Serializ... |
// vmess_parse vmess.json
// curl http | base64 -d | cut vemss.* | base64 -d | jq | json_parse
use base64::{decode, encode};
use std::{
fmt::format,
fs::File,
io::{self, prelude::*, BufReader, Write},
path::Path,
time::{Duration, SystemTime},
};
pub struct Vmess {
pub add: String,
pub host... |
use druid::im::Vector;
use druid::Data;
use scribl_curves::{DrawSnippets, Time};
use crate::audio::TalkSnippets;
use crate::{CurrentAction, SnippetId};
const MAX_UNDO_STACK: usize = 128;
/// This is the part of the editor state that gets restored when we undo/redo.
/// Note that undoing/redoing might also affect ot... |
use piston_window::{*, types::{Color, FontSize}};
use std::{path::Path, {time::Duration, time::Instant}};
use crate::FLASH_TIME;
/// <span style="color:#DB143D; text-shadow: 1px 0.5px #555">█</span>
pub const CRIMSON: Color = [0.86, 0.08, 0.24, 1.0];
/// <span style="color:#292929; text-shadow: 1px 0.5px #555">... |
use aoc_lib::{day, parsers::split_pair, Bench, BenchResult, UserError};
use color_eyre::eyre::{eyre, Result};
use std::collections::HashMap;
day! {
day 14: "Docking Data"
1: run_part1
2: run_part2
}
fn run_part1(input: &str, b: Bench) -> BenchResult {
let instructions: Vec<_> = input
.lines()... |
use funty::Integral;
use graph::{EdgeT, Graph, NodeT, ThreadDataRaceAware};
use indicatif::{ProgressBar, ProgressIterator, ProgressStyle};
use rayon::iter::IntoParallelIterator;
use rayon::iter::IntoParallelRefMutIterator;
use rayon::iter::ParallelIterator;
use rayon::prelude::ParallelSliceMut;
use rayon::prelude::*;
... |
use crypto::random_bytes;
use sodiumoxide::crypto::pwhash::{
pwhash, pwhash_verify, HashedPassword, MEMLIMIT_INTERACTIVE, OPSLIMIT_INTERACTIVE,
};
use std::ops::RangeInclusive;
/// Hash password utily
pub fn create_password<S: AsRef<str>>(password: S) -> Vec<u8> {
(&(pwhash(
password.as_ref().as_bytes(... |
use std::fs::File;
use std::io::Read;
use battle::units::UnitType;
use networking::*;
use utils::clamp;
use toml;
use toml::Value;
use std::path::PathBuf;
type Table = toml::map::Map<String, Value>;
// Extract the table out of a toml value
fn to_table(value: Value) -> Option<Table> {
if let Value::Table(table)... |
pub mod export_section;
pub mod number;
mod code_section;
mod custom_section;
mod data_section;
mod element_section;
mod function_section;
mod global_section;
mod import_section;
mod init_expr;
mod initial_value;
mod memory_section;
mod start_section;
mod table_section;
mod type_section;
mod types;
pub use code_secti... |
//! This crate contains two objects: [`SwitchingSleep`] and [`ASwitchingSleep`].
//!
//! [`ASwitchingSleep`] is just a wrapper around
//! [`Arc`](struct@std::sync::Arc)<[`RwLock`](struct<EMAIL>::RwLock)<[`SwitchingSleep`]>>.
//!
//! They are a [`tokio::time::Sleep`](struct@tokio::time::Sleep) with a
//! switchable stat... |
use super::table;
use super::{HALF_HEIGHT, HALF_WIDTH, WIDTH};
pub fn render(table: &table::Table, fb: &mut [u8], frame: usize) {
const DSPEED: f32 = 1.;
const ASPEED: f32 = 0.2;
let frame = frame as f32;
// Hey look, it's a rare case where I have to optimize bounds checking!
// This routine orig... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.