text stringlengths 3.09k 13.9k |
|---|
use std::collections::HashSet;
use std::hash::Hash;
use std::iter::FusedIterator;
/// Produces all [cycle] paths using
/// [Depth-First Traversal] (in Pre-Order).
///
/// [Depth-First Traversal]: https://en.wikipedia.org/wiki/Tree_traversal
///
/// `DftCycles` produces all paths that contain a [cycle].
/// Thereby all... |
/*
* Copyright 2021 <NAME>
*
* 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 wr... |
use std::path::PathBuf;
use tdn_storage::local::DStorage;
pub mod consensus;
mod account;
mod file;
mod service;
mod session;
use account::ACCOUNT_VERSIONS;
use consensus::CONSENSUS_VERSIONS;
use file::FILE_VERSIONS;
use service::SERVICE_VERSIONS;
use session::SESSION_VERSIONS;
use crate::apps::assistant::ASSISTANT... |
//! The `rpc_service` module implements the Morgan JSON RPC service.
// use crate::treasury_forks::TreasuryForks;
use crate::treasury_forks::TreasuryForks;
use crate::node_group_info::NodeGroupInfo;
use crate::rpc::*;
use crate::service::Service;
use crate::storage_stage::StorageState;
use jsonrpc_core::MetaIoHandler;... |
use onigmo_sys::*;
use std::error;
use std::fmt;
// 本来は`OnigPosition`のままでなくenumを定義して変換した方がいいが長くなるのでここでは省略。
#[derive(Debug, Clone)]
pub struct Error(OnigPosition, Option<OnigErrorInfo>, String);
type Result<T> = ::std::result::Result<T, Error>;
impl Error {
// 中身はほぼonigmo-sysでの記述のままだが、最後に`String`を作っているのでRustから扱いやす... |
use crate::{read_le_bytes, GPTError, Result, GUID};
mod attrs;
pub use attrs::Attributes;
//pub const ESP_GUID_TYPE: GUID = GUID::new()
pub struct GPTPartHeader<T = DefaultGPTTypeGuid, A = Attributes>
where
T: GPTTypeGuid,
{
/// Unique ID that defines the purpose and type of this Partition.
/// A value o... |
// This file is part of Substrate.
// Copyright (C) 2018-2021 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 ... |
use std::fmt;
use std::collections::HashMap;
use std::hash::Hasher;
use plotters::prelude::*;
use std::collections::hash_map::DefaultHasher;
pub struct DataSet {
pub dates : Vec<chrono::NaiveDate>,
pub series : Vec<Series>,
pub regions : Vec<(String,Vec<Region>)>,
}
impl DataSet {
pub fn new(dates : V... |
use std::collections::{HashMap, VecDeque};
use caph_connector::TypeId;
use sqlx::PgPool;
use crate::Error;
use super::{Dependency, DependencyType};
/// Maps product [TypeId] to a dependency containing all its required materials
#[derive(Clone, Debug)]
pub struct DependencyCache(HashMap<TypeId, Dependency>);
impl D... |
// #![allow(unused)]
use clap::ArgMatches;
use std::{
fs::File,
path::{Path, PathBuf},
};
use zip::{write::FileOptions, CompressionMethod::Stored, ZipWriter};
/// Used to store file or folder to be compressed into vpk
struct AddList {
src: PathBuf,
dst: String,
}
/// Default VPK filename
const DEFAUL... |
use derive_more::From;
use err_derive::Error;
use lazy_static::lazy_static;
use log::error;
use regex::Regex;
use validator::Validate;
use speedruns_models::*;
use speedruns_utils::{self as utils, slugify, u64_from_base36};
#[derive(Debug, Error, From)]
pub enum Error {
#[error(display = "all names were None or ... |
use piston_window::*;
use board::Board;
use randomizer::Randomizer;
use tetromino::*;
use settings::*;
use stats::GameStats;
pub struct Rustris {
board: Board,
randomizer: Randomizer,
current_piece: Piece,
next_piece: Piece,
stats: GameStats,
time_since_moved: f64,
state: GameState
}
impl... |
use std::time::Duration;
use reqwest::{Client};
use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT, AUTHORIZATION};
use serde::{Deserialize};
use crate::clients::organizations::OrganizationsClient;
pub mod organizations;
mod api;
fn get_root_url() -> &'static str {
"https://api.github.com"
}
pub struct GitH... |
//! Error and Result module.
use std::error::Error as StdError;
use std::fmt;
use std::io::Error as IoError;
use std::str::Utf8Error;
use std::string::FromUtf8Error;
use httparse;
pub use uri::UriError;
use self::Error::{
Method,
Uri,
Version,
Header,
Status,
Timeout,
Upgrade,
Closed,... |
use crate::messaging::HandlerFnRef;
use crate::actor_system::{World};
use crate::tuning::Tuning;
use chunky;
use crate::id::RawID;
use crate::messaging::Fate;
use super::ActorStateVTable;
use compact::Compact;
use ::std::rc::Rc;
mod slot_map;
use self::slot_map::{SlotMap, SlotIndices};
pub struct InstanceStore {
... |
use super::*;
pub fn iadd64(c1: u64, c2: u64) -> u64 { c1.wrapping_add(c2) }
pub fn isub64(c1: u64, c2: u64) -> u64 { c1.wrapping_sub(c2) }
pub fn imul64(c1: u64, c2: u64) -> u64 { c1.wrapping_mul(c2) }
pub fn idiv_u64(c1: u64, c2: u64) -> u64 { c1.wrapping_div(c2) }
pub fn idiv_s64(c1: u64, c2: u64) -> u64 { c1.wrapp... |
use std::collections::HashMap;
use avro_rs::from_avro_datum;
use avro_rs::to_avro_datum;
use avro_rs::types::Value;
use avro_rs::Schema as SchemaRs;
use pyo3::exceptions;
use pyo3::prelude::*;
use pyo3::types::{PyBytes, PyDict, PyList};
use pyo3::PyDowncastError;
#[pyclass]
struct Schema {
schema: SchemaRs,
}
#... |
use std::cell::RefCell;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use downcast_rs::Downcast;
use wayland_commons::debug;
use wayland_commons::map::ObjectMap;
use wayland_commons::wire::Message;
use wayland_commons::{MessageGroup, ThreadGuard};
use crate::{DispatchData, Filter, Inter... |
use clap::Parser;
use ignore::WalkBuilder;
use std::{
env, fs, os,
path::{Path, PathBuf},
process,
};
use crate::{utils, Result};
#[derive(Debug, Parser)]
#[clap(setting = clap::AppSettings::ArgRequiredElseHelp, about, version)]
pub struct Configman {
#[clap(short, long, conflicts_with = "dry-run")]
... |
extern crate structopt;
#[macro_use]
extern crate structopt_derive;
use structopt::StructOpt;
use std::path::PathBuf;
use std::io::BufReader;
use std::io::prelude::*;
use std::fs::File;
use std::process;
#[derive(StructOpt, Debug)]
#[structopt(name = "AOC2017", about = "An Advent of Code CLI arguments object.")]
stru... |
use std::mem::size_of;
use zerocopy::{AsBytes, ByteSlice, ByteSliceMut, FromBytes, LayoutVerified};
use crate::bsearch::binary_search_by;
use crate::disk_manager::PageId;
use crate::slotted::{self, Slotted};
use super::Pair;
#[derive(Debug, FromBytes, AsBytes)]
#[repr(C)]
pub struct Header {
prev_page_id: PageI... |
use std::fmt::Debug;
use std::io::Read;
use std::mem::replace;
use nom::branch::alt;
use nom::character::complete::newline;
use nom::combinator::map;
use nom::multi::many0;
use nom::sequence::delimited;
use nom::sequence::separated_pair;
use nom::sequence::terminated;
use nom::IResult;
use crate::common::read_input;
... |
use gfx;
use gfx_core;
use gfx::pso::{PipelineData, PipelineInit, DataBind, DataLink};
use gfx::pso::{self, target};
use render::backend;
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq)]
pub struct Meta<R: backend::Backend> {
constants: Vec<gfx::RawConstantBuffer>,
globals: Vec<gfx::RawGlobal>,
color_... |
#![allow(non_snake_case)]
use crate::def_package;
use crate::engine::{FN_TO_STRING, KEYWORD_DEBUG, KEYWORD_PRINT};
use crate::fn_native::FnPtr;
use crate::parser::{ImmutableString, INT};
use crate::plugin::*;
#[cfg(not(feature = "no_index"))]
use crate::engine::Array;
#[cfg(not(feature = "no_object"))]
use crate::en... |
// Copyright 2022, The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// di... |
/* diosix RV64G hardware timer control for scheduler
*
* (c) <NAME>, 2019.
*
* See LICENSE for usage and copying.
*/
use spin::Mutex;
use super::physmem;
extern "C"
{
fn platform_timer_machine_enable();
fn platform_timer_target(target: u64, clint_base: physmem::PhysMemBase);
fn platform_timer_get_tar... |
use zaplib::*;
use zaplib_components::*;
const TEXT_HEADING: TextInsProps = TextInsProps {
text_style: TextStyle { font_size: 28.0, line_spacing: 2.0, ..TEXT_STYLE_NORMAL },
wrapping: Wrapping::Word,
color: COLOR_WHITE,
padding: Padding::all(10.),
..TextInsProps::DEFAULT
};
const TEXT_BODY: TextIns... |
// Definition for singly-linked list.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode { next: None, val }
}
}
pub struct Solution {}
// impl Solution {
// pub fn... |
// Copyright 2020 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
use crate::event_loop::EventLoop;
use rustcommon_fastmetrics::metrics;
use crate::session::*;
use crate::*;
use boring::ssl::{HandshakeError, Ssl, SslContext};
use mio::net::TcpListener;
/... |
//Copyright (c) 2016, <NAME>, <NAME>
//All rights reserved.
use std::collections::BTreeMap;
use std::fmt;
use std::sync::{Arc, Mutex};
use config;
use webhooks;
include!("logger_macros.rs");
////////////////////////////////////////////////////////////
// Command //
/... |
use crate::completions::{Completer, CompletionOptions, MatchAlgorithm, SortBy};
use nu_engine::eval_call;
use nu_protocol::{
ast::{Argument, Call, Expr, Expression},
engine::{EngineState, Stack, StateWorkingSet},
PipelineData, Span, Type, Value,
};
use reedline::Suggestion;
use std::sync::Arc;
pub struct C... |
use byteorder::{ByteOrder, LittleEndian};
use std::io::{self, Read, Write};
use crate::masked_crc::{compute_crc, MaskedCrc};
const LENGTH_CRC_OFFSET: usize = 8;
const DATA_OFFSET: usize = LENGTH_CRC_OFFSET + 4;
const HEADER_LENGTH: usize = DATA_OFFSET;
const FOOTER_LENGTH: usize = 4;
// From TensorFlow `record_write... |
/// Query Info structure size of 41 bytes
const STRUCTURE_SIZE: &[u8; 2] = b"\x29\x00";
use rand::{
distributions::{Distribution, Standard},
Rng,
};
/// The SMB2 QUERY_INFO Request packet is sent by a client to request
/// information on a file, named pipe, or underlying volume.
#[derive(Debug, PartialEq, Eq,... |
use crate::entries::helper::{
generate_claim_key, generate_claim_value, generate_cota_index, generate_define_key,
generate_define_value, generate_hold_key, generate_hold_value, generate_withdrawal_key,
generate_withdrawal_key_v1, generate_withdrawal_value, generate_withdrawal_value_v1,
};
use crate::models:... |
pub type Word = i32;
type Register = u8;
#[derive(Copy, Clone)]
pub enum ValueOrRegister {
Value(Word),
Register(Register),
}
impl ValueOrRegister {
fn parse(input: &str) -> Result<Self, String> {
Ok(if ["a", "b", "c", "d"].contains(&input) {
Self::Register(input.as_bytes()[0] - b'a')
... |
use std::path::{Path, PathBuf};
use std::ffi::OsString;
use std::io::{Error};
use std::process::{Command, ExitStatus};
use std::ops::Deref;
use std::fmt::Debug;
use crate::{BINARY_DIR, is_debug, DYNAMIC_MODE};
use std::sync::atomic::Ordering;
use std::iter::FromIterator;
pub struct Benchmark {
src_dir: PathBuf,
... |
use bytemuck::{ Pod, Zeroable };
use crate::{
assets::{
Id,
Texture,
VertexAttributes,
},
renderer::pipeline::Pipeline,
services::{
Assets,
Renderer,
},
};
/// Overlay widget component
pub struct Widget {
/// list of vertices
pub vertices: Vec<Widge... |
use std::collections::BinaryHeap;
use std::cmp::{Ordering, Ord, PartialOrd, PartialEq};
use std::time::{Instant, Duration};
use event::Event;
use notification::Notification;
/// Store timers in a binary heap. Keep them sorted by which timer is going to expire first.
pub struct TimerHeap {
timers: BinaryHeap<TimerE... |
use crate::{
config::{OpenIdConfig, ProviderConfig},
error::{ApiError, ClientError},
models::NewUserProvider,
schema::user_providers,
util::{self, IdentityState, Pool},
};
use actix_identity::Identity;
use actix_web::{get, http, post, web, HttpResponse};
use diesel::{
ExpressionMethods, Optional... |
/*
* Copyright 2018 Fluence Labs 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 by applicable law or a... |
mod config;
mod models;
use std::{io, path::PathBuf};
use actix_cors::Cors;
use actix_governor::{Governor, GovernorConfigBuilder};
use actix_web::{
get, post,
web::{self, Data},
App, HttpResponse, HttpServer, Responder,
};
use config::Config;
use chrono::Duration;
use models::{
ApiError, ApiResponse,... |
//https://github.com/serde-rs/serde/pull/238
use serde::{Deserialize, Serialize};
use std::fmt;
type EstimateDirection = String;
type NodeType = String;
/// The Plan struct
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Plan {
#[serde(default, rename(deserialize = "Actual Cost"))]
pub actual_cost:... |
extern crate fuzzy_pickles;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
use std::fs::File;
use std::env;
use std::io::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
use fuzzy_pickles::{ast, visit::{Visit, Visitor, Control}, HasExtent};
#[derive(Debug, Copy, Clone, PartialOrd, Ord, Parti... |
use std::collections::VecDeque;
use std::fs;
use std::io;
use std::path::PathBuf;
use std::str;
use builtin::commit;
use builtin::read_tree;
use index;
use object;
use object::Object;
use refs;
#[derive(Debug)]
pub enum Error {
CommitError(commit::Error),
IndexError(index::Error),
IoError(io::Error),
... |
use crate::ihdr::ColorMode;
use crate::ihdr::InterlaceMethod;
use crate::ihdr::Palette;
use crate::Error;
use crate::Result;
#[derive(Copy, Clone)]
enum FilterType {
None,
Sub,
Up,
Average,
Paeth,
}
impl FilterType {
fn read(filter_type: u8) -> Result<FilterType> {
use FilterType::*;
... |
use std::collections::HashMap;
use std::convert::TryInto;
use ffi_support::FfiStr;
use super::error::{catch_error, ErrorCode};
use super::object::{IndyObject, IndyObjectId, IndyObjectList, ObjectHandle};
use super::util::{FfiList, FfiStrList};
use crate::error::Result;
use crate::services::{
prover::create_presen... |
use crate::nts_ke::client::NtsKeResult;
use miscreant::aead::Aead;
use miscreant::aead::Aes128SivAead;
use rand::Rng;
use slog::{debug};
use std::error::Error;
use std::fmt;
use std::net::{UdpSocket, ToSocketAddrs};
use std::time::{Duration, SystemTime};
use super::protocol::parse_nts_packet;
use super::protocol::se... |
use rand::{thread_rng, Rng};
use super::*;
pub struct Simulation {
iterations: usize,
crossover_probability: f64,
mutation_probability: f64,
population_size: usize,
number_of_cities: usize,
cities: Vec<city::City>,
number_of_mutations: usize,
number_of_crossovers: usize,
pub fi... |
use crate::{
error::{Error, Result},
utils::{crc, math, unsafe_utils},
};
use parking_lot::RwLock;
use std::collections::VecDeque;
pub mod file_source;
pub mod memory_source;
pub use file_source::FileSource;
pub use memory_source::MemorySource;
pub trait Source: Send + Sync {
fn is_byte_addressable(&self... |
use super::Atom;
macro_rules! gen_tests {
(
$mod_name:ident, $ty:ty, $val0:expr, $val1:expr,
[
$with_logic:ident $with_int:ident
$with_default:ident $with_serde:ident
]
) => {
mod $mod_name {
use crate::{Atomic, Ordering};
#[test]... |
use crate::{
cmd::{self, Result},
input,
models::{self, CMD_ITEM_CREATE, CMD_ITEM_DELETE, CMD_ITEM_UPDATE},
sqlite, utils, Context,
};
pub fn add(ctx: &mut Context) -> Result<()> {
let mut list: models::List;
let mut title: Option<String> = None;
let mut description: Option<String> = None;
... |
use clap::ArgMatches;
use network::{unused_port, Enr, Multiaddr, NetworkConfig, DEFAULT_CLIENT_NAME};
use std::path::PathBuf;
pub const DEFAULT_DEBUG_LEVEL: &str = "info";
/// Mothra configuration
pub struct Config {
/// The client name
pub client_name: String,
/// The client version
pub client_versi... |
use gcd::Gcd;
use std::fmt;
use std::collections::HashMap;
// ================================================== STRUCTS ==================================================
type CoordinateUnit = i64;
#[derive(Clone)]
struct Point {
x: CoordinateUnit,
y: CoordinateUnit,
}
#[derive(PartialEq)]
enum L... |
// Copyright 2016 The Grin Developers
//
// 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 agree... |
use nile::{console, Coordinates, Engine, Player, SelectedTile, TilePath, TilePathType};
use yewdux::prelude::{Reducer, ReducerStore};
use crate::components::utils::update_if_changed;
#[derive(Clone)]
pub struct State {
/// Main game state
pub nile: Engine,
/// Modal state for displaying errors and end-of-... |
use actix_web::http::StatusCode;
use actix_web::{
error::ResponseError, get, middleware::Logger, post, web, App, HttpRequest, HttpResponse,
HttpServer, Responder,
};
use chrono::prelude::*;
use log::*;
use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
use serde::{Deserialize, Serialize};
use std::colle... |
#![forbid(unsafe_code)]
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate shrinkwraprs;
#[macro_use]
extern crate log;
#[macro_use]
extern crate eyre;
extern crate fs_extra;
mod config;
mod executor;
mod script;
mod scriptmap;
mod ui;
mod util;
use scriptmap::ScriptMap;
use sourceview::{Language, Lang... |
// Copyright 2022 <NAME>
//
// 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 writi... |
use specs::prelude::*;
use quicksilver::prelude::*;
use crate::prelude::*;
use crate::net::game_master_api::RestApiState;
use crate::logging::ErrorQueue;
use crate::game::{
movement::*,
town_resources::TownResources,
units::workers::*,
components::*,
town::{Town, DefaultShop},
};
use crate::net::st... |
//! `Template` Raw Format
//!
//! +_____________________________________________________+
//! | | |
//! | version | name |
//! | (2 bytes) | (String) |
//! +____________|__________________________... |
use crate::types::*;
use crossbeam_channel::Sender;
use jsonrpc_core::{self, Call, Error, Failure, Id, Output, Success, Value, Version};
use lsp_types::notification::Notification;
use lsp_types::request::*;
use lsp_types::*;
use serde::Deserialize;
use std::borrow::Cow;
use std::collections::HashMap;
use std::{fs, time... |
/**
* [0468] Validate IP Address
*
* Given a string queryIP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type.
* A valid IPv4 address is an IP in the form "x1.x2.x3.x4" where 0 <= xi <= 255 and xi cannot contain leading zeros. For e... |
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
chained_bft::block_storage::BlockReader,
counters,
state_replication::TxnManager,
util::time_service::{wait_if_possible, TimeService, WaitingError, WaitingSuccess},
};
use consensus_types::{
block::Bloc... |
use std::convert::TryInto;
use std::sync::Arc;
use bytes::BytesMut;
use observability_deps::tracing::debug;
use prost::Message;
use tonic::Response;
use data_types::job::Job;
use generated_types::google::FieldViolationExt;
use generated_types::{
google::{
longrunning::*,
protobuf::{Any, Empty},
... |
/*
Copyright ⓒ 2015 <NAME>.
Licensed under the MIT license (see LICENSE or <http://opensource.org
/licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of
<http://www.apache.org/licenses/LICENSE-2.0>), at your option. All
files in the project carrying such notice may not be copied, modified,
or distributed e... |
// Rust: The data should be loaded from the on-disk list of files, rather than each type individually.
// The file naming actually helps, since "map" textures don't have an index.
use std::{collections::HashMap, error};
use macroquad::{
audio::{self, load_sound, Sound},
prelude::{load_texture, Texture2D},
};
... |
#![cfg(feature = "conform")]
#![allow(non_snake_case)]
extern crate env_logger;
#[macro_use]
extern crate log;
extern crate ndarray;
#[macro_use]
extern crate proptest;
extern crate protobuf;
extern crate tensorflow;
extern crate tract_core;
extern crate tract_tensorflow;
mod utils;
use crate::utils::*;
use ndarray::... |
use crate::orchestrator::utils::ssh_access::{read_remote_file, AuthMean};
use ic_replay::cmd::{ClapSubnetId, ReplayToolArgs, RestoreFromBackupCmd, SubCommand};
use ic_types::SubnetId;
use slog::{info, Logger};
use std::net::IpAddr;
use std::path::{Path, PathBuf};
use std::process::Command;
const BACKUP_DIR: &str = "./... |
use std::cmp::Ordering;
use std::error::Error;
use std::fmt::{self, Formatter};
use std::hash::Hash;
use std::hash;
use std::sync::Arc;
use regex::Regex;
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
use semver;
use util::{CargoResult, CargoError, ToSemver};
use core::source::SourceId;
/// Identifie... |
use std::fmt;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::process::Command;
// constants as defined in spectrwm config
const WHITE: u8 = 0;
const GREY: u8 = 4;
const RED: u8 = 3;
const ORANGE: u8 = 2;
// file locations
const BAT1: &str = "/sys/class/power_supply/BAT0/capacity";
const BAT2: &str = "... |
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Portions Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the THIRD-PARTY file.
use kvm_bindings::kvm... |
use ::std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
use ::std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use crate::network::{Connection, LocalSocket, Utilization};
static RECALL_LENGTH: usize = 5;
pub trait Bandwidth {
fn get_total_bytes_downloaded(&self) -> u128;
fn get_total_bytes_uploaded(&self) -> ... |
use na::Matrix4;
use std::{cell::RefCell, rc::Rc};
use crate::graphics::{position, position::WindowCorner, Drawable, Font, Rectangle};
use crate::gui::{Label, UiElement};
use crate::State;
/// Vertical offset factor for the label.
const LABEL_V_FAC: f32 = 1.5;
/// A simple slider giving a value from 0.0 to 1.0.
pub ... |
//! An implementation of the [BLAKE2][1] hash functions.
//!
//! # Usage
//!
//! [`Blake2b512`] and [`Blake2s256`] can be used in the following way:
//!
//! ```rust
//! use blake2::{Blake2b512, Blake2s256, Digest};
//! use hex_literal::hex;
//!
//! // create a Blake2b512 object
//! let mut hasher = Blake2b512::new();
/... |
// Copyright 2020 <NAME>
// SPDX-License-Identifier: Apache-2.0
#![allow(dead_code)]
use wasmlib::*;
pub const SC_NAME: &str = "testcore";
pub const SC_DESCRIPTION: &str = "Core test for ISCP wasmlib Rust/Wasm library";
pub const SC_HNAME: ScHname = ScHname(0x370d33ad);
pub const PARAM_ADDRESS: &str = "address";
pu... |
//! Builder of SAC agent.
use crate::{
model::{SubModel, SubModel2},
replay_buffer::{ReplayBuffer, TchBuffer},
sac::{
actor::Actor,
critic::Critic,
ent_coef::{EntCoef, EntCoefMode},
SAC,
},
util::{CriticLoss, OptInterval, OptIntervalCounter},
};
use anyhow::Result;
us... |
extern crate coord_2d;
extern crate grid_2d;
extern crate image;
extern crate rand;
extern crate wfc;
pub use coord_2d::{Coord, Size};
use grid_2d::Grid;
use image::{DynamicImage, Rgba, RgbaImage};
use rand::Rng;
use std::num::NonZeroU32;
use wfc::orientation::OrientationTable;
pub use wfc::orientation::{self, Orienta... |
use super::{super::config::Config, IoStream};
use anyhow::{Error, Result};
use log::*;
use mpsc::{Receiver, Sender};
use std::net::{Ipv4Addr, SocketAddr};
use std::{sync::Arc, time::Duration};
use tokio::{
net::{TcpListener, TcpStream},
sync::mpsc,
task::JoinHandle,
time::timeout,
};
use tokio_rustls::{... |
//! Providing the features between "full" and "derive" of syn.
//!
//! This crate provides the following two unique data structures.
//!
//! * [`syn_mid::ItemFn`] -- A function whose body is not parsed.
//!
//! ```text
//! fn process(n: usize) -> Result<()> { ... }
//! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ ^
/... |
// Copyright 2018 The Exonum 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 to i... |
use super::traits::*;
use super::notify_fn::*;
use futures::*;
use futures::task;
use futures::task::{Poll};
use ::desync::*;
use std::pin::{Pin};
use std::sync::*;
use std::marker::PhantomData;
///
/// The state of the binding for a follow stream
///
#[derive(Copy, Clone)]
enum FollowState {
Unchanged,
Ch... |
//! This pass is only used for UNIT TESTS related to incremental
//! compilation. It tests whether a particular `.o` file will be re-used
//! from a previous compilation or whether it must be regenerated.
//!
//! The user adds annotations to the crate of the following form:
//!
//! ```
//! #![rustc_partition_reused(mod... |
use orbtk::prelude::HashMap;
fn two_sum(nums: &[i32], target: i32 , result: &mut Vec<usize>) {
if nums.len() == 0 {
return;
}
let mut m = HashMap::new();
for i in 0..nums.len() {
let a = (target-nums[i]) as usize ;
if m.contains_key(&a) {
result.push(i);
match m.... |
use smoltcp::socket::{UdpPacketMetadata, UdpSocket, UdpSocketBuffer};
use smoltcp::iface::{SocketHandle};
use smoltcp::wire::IpEndpoint;
use std::str;
use syscall;
use syscall::{Error as SyscallError, Result as SyscallResult};
use super::socket::{DupResult, SchemeFile, SchemeSocket, SocketFile, SocketScheme};
use supe... |
use std::sync::{Arc, Mutex};
use chrono::Utc;
use futures::stream::{FuturesUnordered, StreamExt};
use tower::{Service, ServiceExt};
use tracing::Level;
use crate::{types::MetaAddr, AddressBook, BoxedStdError, Request, Response};
/// The `CandidateSet` maintains a pool of candidate peers.
///
/// It divides the set o... |
use std::fmt;
use std::fs::File;
use std::io::{self, BufRead};
use std::str::FromStr;
use itertools::Itertools;
#[derive(Debug)]
enum Entry {
StrVal(String),
IntVal(u32),
}
#[derive(Default, Debug)]
struct Passport {
birth_year: Option<Entry>,
issue_year: Option<Entry>,
exp_year: Option<Entry>,
... |
use super::iface::Tap;
use crate::Never;
use futures::sync::{mpsc, oneshot};
use futures::{try_ready, Async, Future, Poll, Stream};
use tracing::{debug, trace, warn};
pub fn new<T>() -> (Daemon<T>, Register<T>, Subscribe<T>) {
let (svc_tx, svc_rx) = mpsc::channel(super::REGISTER_CHANNEL_CAPACITY);
let (tap_tx,... |
use std::{
collections::BTreeMap,
sync::{
atomic::{AtomicUsize, Ordering::Relaxed},
mpsc::{sync_channel, Receiver, SyncSender},
Arc, RwLock,
},
};
use futures::{
future::Future,
sync::oneshot::{
channel as future_channel, Receiver as FutureReceiver,
Sender as... |
//! Handle network connections for a varlink service
#![allow(dead_code)]
use std::net::TcpStream;
#[cfg(unix)]
use std::os::unix::io::IntoRawFd;
#[cfg(unix)]
use std::os::unix::net::UnixStream;
use std::process::Child;
#[cfg(unix)]
use libc::{close, dup2, getpid};
use tempfile::TempDir;
#[cfg(windows)]
use uds_wind... |
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::CompositeTemplate;
use std::rc::Rc;
use crate::app::components::EventListener;
use crate::app::credentials::Credentials;
use crate::app::state::{LoginCompletedEvent, LoginEvent};
use crate::app::AppEvent;
use super::LoginModel;
mod imp {
use libadwaita... |
use std::sync::Arc;
use crate::{
guest_mem::{GuestMem, MappedMemory},
page_table::{estimate_page_table_size, VirtMem},
};
use log::debug;
use nix::sys::mman::ProtFlags;
use simple_error::{bail, require_with, try_with};
use vm_device::bus::{MmioAddress, MmioRange};
use crate::{page_math, result::Result};
use ... |
//! This module contains a patcher which adjusts memory permissions to patch read-only data
use region::Protection;
use thiserror::Error;
use super::{PatchGuard, Patcher};
/// Errors when using permission patching
#[derive(Debug, Error)]
pub enum PermissionError<E> {
/// Error when setting memory protections
... |
// Copyright 2020, The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// di... |
use daml_grpc::data::package::DamlPackage;
use daml_grpc::data::{DamlError, DamlResult};
use daml_grpc::DamlGrpcClient;
use daml_lf::{DamlLfArchive, DamlLfArchivePayload, DamlLfHashFunction, DarFile, DarManifest};
use futures::stream::FuturesUnordered;
use futures::StreamExt;
use uuid::Uuid;
/// Convenience methods fo... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - This register contains a random 32 bit number which is computed on demand, at each time it is read"]
pub random_number: RANDOM_NUMBER,
_reserved1: [u8; 4usize],
#[doc = "0x08 - no description available"]
pub counter_val... |
use std::error::Error;
use std::sync::mpsc::{channel, TryRecvError};
use std::sync::{Arc, Mutex};
use std::thread;
use crate::config::*;
use crate::status::*;
use crate::worker::{monitor_thread, ShuttingDown};
/// We don't want to store the actual sender in the MonitorThread, just a boxed version of it that
/// will ... |
#![allow(missing_docs)]
#[warn(missing_docs)]
pub mod glsl;
use enso_prelude::*;
use js_sys::Float32Array;
use web_sys::WebGl2RenderingContext;
use web_sys::WebGlBuffer;
use web_sys::WebGlProgram;
use web_sys::WebGlShader;
// ===============
// === Exports ===
// ===============
/// Common types.
pub mod types {... |
use std::net::IpAddr;
use tokio::{runtime::Handle, task::block_in_place};
use crate::prelude::*;
use super::grinder::Grinder;
use bob_common::metrics::SharedMetricsSnapshot;
/// Struct contains `Grinder` and receives incomming GRPC requests
#[derive(Clone, Debug)]
pub struct Server {
handle: Handle,
grinder... |
use Query;
use futures::{Async, Poll, Stream};
use futures::sync::mpsc::UnboundedSender;
use linear_map::LinearMap;
use pg::FrontendMessage;
use postgres_protocol;
use postgres_protocol::message::backend::Message as BackendMessage;
use std::io::Error as IoError;
use std::io::ErrorKind;
use stream_fold::StreamFold;
use ... |
use crate::auth::OAuthReq;
use crate::oautherror::OAuthError;
use graph_error::GraphFailure;
use serde_json::Map;
use serde_json::Value;
use std::collections::HashMap;
use std::convert::TryFrom;
use std::str::FromStr;
/// Enum for the type of JSON web token (JWT).
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.