text stringlengths 3.09k 13.9k |
|---|
//! Draw 2D graphics for your users.
//!
//! A [`Canvas`] widget can be used to draw different kinds of 2D shapes in a
//! [`Frame`]. It can be used for animation, data visualization, game graphics,
//! and more!
//!
//! [`Canvas`]: struct.Canvas.html
//! [`Frame`]: struct.Frame.html
use crate::{Defaults, Primitive, Re... |
use anyhow::{Context, Result};
use spidev::{Spidev, SpidevOptions};
use tokio::{fs::File, io::AsyncReadExt, process::Command, sync::Mutex};
use tracing::{debug, error};
use std::{io::prelude::*, path::Path, process::Stdio, sync::Arc};
#[derive(Clone)]
pub struct Spi {
dev: Arc<Mutex<Spidev>>,
}
impl Spi {
pu... |
use std::str::FromStr;
use std::sync::{Arc, Mutex};
use anyhow::Context;
use datis_core::{
mission_info::{Clouds, MissionInfo, WeatherInfo},
station::Position,
};
use hlua51::{Lua, LuaFunction, LuaTable};
#[derive(Debug)]
pub struct DcsMissionInfoInner {
lua: Lua<'static>,
clouds: Option<Clouds>,
... |
// Simplified version of npm-package-json
// https://github.com/SirWindfield/npm-package-json
use crate::utils::helpers;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::io::ErrorKind;
use std::{collections::BTreeMap, fs};
/// An ordered map for `bin` entries.
pub type BinSet = BTreeMap<String, St... |
//! # markov_rs
//!
//! A simple and fast Markov chain generator in Rust.
//!
//! By using Walker's Alias Method, a weighted random sampling
//! algorithm, the model can generate elements very quickly.
//!
//! ## Example
//!
//! ```rust
//! use markov_rs::MarkovChain;
//!
//! fn main() {
//! let text = [
//! ... |
#![allow(
dead_code,
unused_imports,
clippy::needless_range_loop,
clippy::ptr_arg,
clippy::char_lit_as_u8
)]
use std::char;
use std::cmp::{max, min};
use std::fmt;
use std::io::BufRead;
use std::iter::*;
use std::ops::*;
use std::str;
use std::str::FromStr;
use std::{io, process};
use failure::bai... |
use super::engine::composition::{GraphId, MatchGraph, PosMatcher};
use crate::types::*;
use crate::{
tokenizer::Tokenizer,
utils::{self, regex::SerializeRegex},
};
use onig::Captures;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
impl std::cmp::PartialEq for Suggestion {
fn eq(&self, ... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// 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 ... |
use aes_ctr::cipher::generic_array::GenericArray;
use aes_ctr::cipher::{NewStreamCipher, SyncStreamCipher};
use aes_ctr::Aes128Ctr;
use hmac::{Hmac, Mac};
use librespot_core::{authentication::Credentials, diffie_hellman::DhLocalKeys};
use sha1::{Digest, Sha1};
/// Add a number in the output stream
///
/// Numbers are ... |
// Copyright (c) 2019 <NAME> <<EMAIL>>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::ns;
use crate::util::error::Error;
use crate::Element;
use std::c... |
use std::{
sync::Arc,
time::Instant,
};
use rustc_hash::FxHashMap;
use ra_syntax::{
AstNode, SyntaxNode,
ast::{self, NameOwner, ModuleItemOwner}
};
use ra_db::{SourceRootId, FileId, Cancelable,};
use crate::{
SourceFileItems, SourceItemId, DefKind, Function, DefId, Name, AsName,
db::HirDatabas... |
// Copyright (c) 2018 <NAME>, RWTH Aachen University
//
// MIT License
//
// 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... |
#[cfg(test)]
mod tests;
use display::DisplayColor;
use input::{Event, EventHandler, InputOptions, KeyCode, KeyEvent, KeyModifiers};
use lazy_static::lazy_static;
use unicode_segmentation::UnicodeSegmentation;
use view::{LineSegment, ViewData, ViewLine};
lazy_static! {
static ref INPUT_OPTIONS: InputOptions = InputOp... |
use seed::prelude::*;
use std::fmt::Write;
use wasm_bindgen::JsCast;
use crate::counter::Counter;
use crate::stats;
use crate::Msg;
const XMIN: f32 = 0.0;
const YMIN: f32 = 0.0;
const WIDTH: f32 = 100.0;
const HEIGHT: f32 = 60.0;
/// SVG elements for displaying the results within the graph. If `highlight` is
/// gi... |
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use sqlx::Transaction;
use uuid::Uuid;
use crate::{sqlx, DatabaseError};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Account {
pub id: i64,
pub username: String,
pub administrator: bool,
pub display_name: Option<String>,
... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Status register"]
pub sr: SR,
#[doc = "0x04 - Data register"]
pub dr: DR,
#[doc = "0x08 - Baud rate register"]
pub brr: BRR,
#[doc = "0x0c - Control register 1"]
pub cr1: CR1,
#[doc = "0x10 - Control reg... |
pub const COOKIE_KEY: &'static str = "tilings_account_id";
#[cfg(not(target_arch = "wasm32"))]
mod auth {
use super::*;
use argon2;
use base64;
use db_conn::DbConn;
use diesel::{self, PgConnection, prelude::*};
use lazy_static::lazy_static;
use models::*;
use r2d2_redis::{r2d2::Pool, re... |
use crate::proto_example::greeter_service_server::GreeterService;
use crate::proto_example::{
Acknowledgement, Empty, GreetCommand, GreetedEvent, Greeting, RecordCommand, SearchQuery,
SearchResponse, StopCommand,
};
use anyhow::{Error, Result};
use bytes::Bytes;
use dendrite::axon_utils::{
init_command_send... |
/*
* Rust-music-player - Copyright (c) 2014 <NAME>.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
* the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including... |
//! Shows basic usage of users and permissions.
use std::time::Duration;
use bonsaidb::{
client::{url::Url, Client},
core::{
admin::{PermissionGroup, Role},
connection::{
AsyncStorageConnection, Authentication, AuthenticationMethod, SensitiveString,
},
permissions::... |
// File: day_16.rs
// Author: <NAME>
// Date: December 2020
/*
Copyright 2020 <NAME>
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 t... |
use crate::{encode, Channel, ERR_PREFIX};
use bstr::BStr;
use std::io;
/// A borrowed packet line as it refers to a slice of data by reference.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum Borrowed<'a> {
/... |
use std::fmt;
use abc::RenderResult;
use VarContext;
use container::expression::*;
pub fn render_expr<W: fmt::Write>(writer: &mut W, context: &VarContext, expr: &DisjExpr) -> RenderResult<()> {
let mut itr = expr.list.iter();
match itr.next() {
None => unreachable!(),
Some(conj) => {
... |
use eyre::{eyre, WrapErr};
use rocket::http::Status;
use rocket::serde::json::Json;
use serde::Serialize;
//use tracing::debug;
use super::competency;
use super::cycle::Cycle;
use super::db;
use super::jwt;
use super::period;
use super::students;
#[derive(Debug, Serialize)]
pub struct EvalStatsByCycleByCompetency {
... |
//!
//! Parsing of ABNF Core Rules
//!
//! See <https://tools.ietf.org/html/rfc5234#appendix-B.1>
//!
pub mod complete;
pub mod streaming;
use nom::AsChar;
/// A-Z / a-z
///
/// ALPHA = %x41-5A / %x61-7A
pub fn is_alpha(c: impl AsChar) -> bool {
matches!(c.as_char(), '\x41'..='\x5A' | '\x61'..='\x7A')
}
/// BIT... |
#![feature(type_alias_impl_trait)]
use cdrs::cluster::TcpConnectionPool;
use cdrs::frame::IntoBytes;
use database::DataSourceConfig;
use werkflow_config::{read_config, ConfigSource};
use cdrs::types::prelude::{TryFromRow, TryFromUDT};
use cdrs_helpers_derive::*;
use cdrs::types::from_cdrs::FromCDRSByName;
use anyho... |
use core::cell::RefCell;
extern {
fn GPIO_OpenAsOutput(gpio_id: i32, output_mode: i8, value_type: i8) -> i32;
fn GPIO_SetValue(fd: i32, value_type: i8) -> i32;
fn sleep(seconds: u32) -> ();
fn Networking_IsNetworkingReady(is_ready: &mut bool) -> i32;
}
pub const MT3620_GPIO8: i32 = 8;
pub const MT3620... |
use std::fmt;
use tokio::sync::mpsc::{channel, Sender};
use tonic::codec::Streaming;
use tonic::transport::channel::Channel;
use crate::error::{LeaseError, Result};
use crate::pb::{self, lease_client::LeaseClient as PbLeaseClient};
use crate::EtcdClient;
use helper::*;
const MPSC_CHANNEL_SIZE: usize = 1;
pub struc... |
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io;
use std::io::ErrorKind::InvalidData;
use std::io::{Error, Read};
use std::str::FromStr;
#[derive(Debug, PartialEq)]
struct Step(char, u32);
impl FromStr for Step {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
... |
use crate::reactive_state_access::state_access::{CloneState, StateAccess};
use crate::{
reactive_state_functions::{execute_reaction_nodes, STORE},
store::{ReactiveContext, SlottedKey, StorageKey, TopoKey},
unmount::Unmount,
};
use std::{cell::RefCell, collections::HashSet};
// thread_local! {
// static... |
//! Adapt the Winsock2 API to resemble a POSIX-style libc API.
#![allow(unused_imports)]
#![allow(non_camel_case_types)]
use windows_sys::Win32::Networking::WinSock;
pub(crate) use libc::{
c_char, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, c_ulong, c_ulonglong,
c_ushort, ssize_t,
};
pub(cr... |
// event.rs
//
// Copyright (c) 2020 <NAME>
//
use crate::layout::{Dim, Pos};
use crossterm::event::Event as CtEvent;
use crossterm::event::MouseButton as CtMouseButton;
use crossterm::event::MouseEvent as CtMouseEvent;
use crossterm::event::{KeyCode, KeyModifiers, MouseEventKind};
/// Widget focus event
#[derive(Clo... |
use rand::prelude::*;
use rand_chacha::ChaCha8Rng;
use crate::types::{BitBoard, BitCoord, Colour, GameState, Piece, ZobristHash};
static mut DEFAULT_HASHER: Option<ZobristHasher> = None;
#[derive(Clone, Copy, Debug)]
pub struct ZobristHasher {
numbers: [u64; 781],
}
impl ZobristHasher {
const DEFAULT_SEED:... |
use crate::{
ctx,
game_graph::{GGD_BufferStatus::*, *},
game_graph_driver::*,
};
use futures::task::SpawnExt;
use half::f16;
use log::trace;
use nice_engine::{
resources::TextureResource,
texture::{ImmutableTexture, TargetTexture},
threads::{yield_once, FILE_THREAD},
};
use std::{ptr::null, slice, sync::Arc, time... |
use crate::coltypes::*;
use crate::er::{err_msg, MyLibError, Result};
use indexmap::IndexMap;
#[derive(Debug)]
pub struct TableDef {
pub name: String,
pub fields: IndexMap<String, ColumnDef>,
// The keys are registered on or
// moved to the ColumnDef unless the key consist of
// several cols
/... |
use std::collections::{HashMap, HashSet};
use std::convert::Infallible;
use std::rc::Rc;
use std::sync::Arc;
use gimli::{AttributeValue, EndianRcSlice, LittleEndian, Reader, SectionId};
use gimli::constants::*;
use itertools::Itertools;
use crate::dwarf::util::DwarfEntry;
#[derive(Debug)]
pub struct DwarfBinary<R: R... |
/*
* Created on Tue Dec 15 2020
*
* Copyright (c) storycraft. Licensed under the Apache Licence 2.0.
*/
use std::{collections::{HashMap, hash_map::{Iter, Values}}, convert::TryFrom, io::{Cursor, Read, Write}};
use byteorder::LittleEndian;
use flate2::{Compression, read::{ZlibDecoder, ZlibEncoder}};
use crate::XP... |
#![cfg(target_os = "macos")]
mod common;
use common::start_child_and_return;
use minidump::{
CrashReason, Minidump, MinidumpBreakpadInfo, MinidumpMemoryList, MinidumpMiscInfo,
MinidumpModuleList, MinidumpSystemInfo, MinidumpThreadList,
};
use minidump_writer::minidump_writer::MinidumpWriter;
fn get_crash_rea... |
use helpers::input_lines;
use scan_fmt::scan_fmt;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::ops::RangeInclusive;
const INPUT: &str = include_str!("../input.txt");
#[derive(Debug)]
struct Ticket {
field_values: Vec<usize>,
}
impl Ticket {
fn invalid_field_values(
&self,
fiel... |
use std::collections::{BTreeMap, VecDeque};
use anyhow::Result;
use crate::{osm, IntersectionType, OriginalRoad, RawMap, RestrictionType};
// TODO After merging a road, trying to drag the surviving intersection in map_editor crashes. I
// bet the underlying problem there would help debug automated transformations ne... |
// Copyright (c) 2018-2020 MobileCoin Inc.
//! A utility to play back SCP messages logged by `LoggingScpNode`.
use mc_common::{logger::log, NodeID};
use mc_consensus_scp::{
scp_log::{LoggedMsg, ScpLogReader, StoredMsg},
test_utils::{get_bounded_combine_fn, trivial_validity_fn},
Msg, Node, QuorumSet, ScpNo... |
//! Claim bid winnings into a target safe account, only the authorised key can do this, though the
//! target can be any safe account.
use crate::{
errors::AuctionError,
processor::{AuctionData, AuctionDataExtended, BidderMetadata, BidderPot},
utils::{
assert_derivation, assert_initialized, assert_... |
//! stm32ral module for stm32f0x1
/// Number of priority bits implemented by the NVIC
pub const NVIC_PRIO_BITS: u8 = 2;
/// Interrupt-related magic for this device
pub mod interrupts;
pub use self::interrupts::Interrupt;
pub use self::interrupts::Interrupt as interrupt;
pub use super::instances::adc;
pub use super::... |
use convert;
use syn::{self, Stmt, Expr, Ident};
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use proc_macro2::Span;
use proc_macro::TokenStream;
use quote::ToTokens;
//fn filter_tts_by_span(span: Span, tts: &[TokenTree]) -> Vec<TokenTree> {
// tts.iter()
// .filter(|tt| span.lo <= t... |
// The windows scheduler is unmaintained and due for a rewrite.
//
// Rather than use a polling mechanism for file read/write readiness,
// it checks readiness just once, before sleeping for any timer subscriptions.
// Checking stdin readiness uses a worker thread which, once started, lives for the
// lifetime of the p... |
use core::cell::RefCell;
use num::Complex;
use regex::Regex;
use std::cmp::Ordering;
use std::collections::{BinaryHeap, HashMap};
type Lattice = Complex<i32>;
const GEOLOGIC_X_CONSTANT: i32 = 16807;
const GEOLOGIC_Y_CONSTANT: i32 = 48271;
const EROSION_CONSTANT: i32 = 20183;
struct RiskCalculator {
calculated: Re... |
use super::pmio::{pmio_config_read_addr, pmio_config_write_addr};
use super::PciAddrSpace;
use numeric_enum_macro::numeric_enum;
#[derive(Debug)]
pub struct PciConfig {
pub addr_space: PciAddrSpace,
pub base: usize,
}
#[allow(unsafe_code)]
impl PciConfig {
pub fn read8_offset(&self, offset: usize) -> u8 {... |
use docopt::Docopt;
use rust_decimal::Decimal;
use serde::Deserialize;
use std::fs::{File, OpenOptions};
use std::io::prelude::*;
use std::str::FromStr;
use libhsbc::category::{Category, UNKNOWN_CATEGORY};
use libhsbc::parser::Parser;
use libhsbc::transaction::Transaction;
const USAGE: &str = "
HSBC Statement Parser
... |
//! *Zcash circuits and proofs.*
//!
//! `zcash_proofs` contains the zk-SNARK circuits used by Zcash, and the APIs for creating
//! and verifying proofs.
// Catch documentation errors caused by code changes.
#![deny(intra_doc_link_resolution_failure)]
use bellman::groth16::{prepare_verifying_key, Parameters, Prepared... |
#![cfg(test)]
use super::*;
use crate as single_app;
use frame_support::{
impl_outer_event, impl_outer_origin, impl_outer_dispatch,
parameter_types, weights::Weight
};
use frame_system as system;
use sp_core::{sr25519, Pair, H256};
use pallet_balances;
use sp_runtime::testing::Header;
use sp_runtime::traits::... |
use core::str;
pub trait Output {
type Token;
type Out;
type Err;
fn is_full(&self) -> bool;
fn push(&mut self, token: Self::Token);
fn take_out(self) -> Result<Self::Out, Self::Err>;
}
pub trait IntoOutput {
type Token;
type IntoOut;
fn into_output(self) -> Self::IntoOut;
}... |
use crate::*;
use std::path::Path;
use wgpu_glyph::ab_glyph;
/// Font data that is readily available to be rendered.
///
/// This **requires** a depth stencil state as text draw calls cannot be visually interleaved with regular draw calls otherwise.
#[derive(Debug)]
pub struct FontBrush {
pub brush: wgpu_glyph::Gl... |
// Copyright (c) 2018-2021 The MobileCoin Foundation
//! Miscellaneous attributes structure
/// A mask of select bits, currently this must be initialized to zero.
pub use mc_sgx_core_types_sys::sgx_misc_select_t as MiscSelect;
/// The size of a [MiscSelect], in bytes.
pub use mc_util_encodings::INTEL_U32_SIZE as MIS... |
use std::{error::Error, fmt, fs::File, io, num::NonZeroI64, os::unix::io::AsRawFd};
/// Memory mapped advise type
#[repr(i32)]
#[allow(dead_code)]
pub enum MemoryAdvice {
Normal = libc::POSIX_MADV_NORMAL,
Sequential = libc::POSIX_MADV_SEQUENTIAL,
Random = libc::POSIX_MADV_RANDOM,
WillNeed = libc::POSIX... |
use amethyst::assets::{Asset, AssetStorage, Handle, PrefabData, PrefabError, ProgressCounter};
use amethyst::ecs::*;
use amethyst::shred::ResourceId;
use log::*;
use serde::de::DeserializeOwned;
use serde::*;
use std::collections::HashMap;
use std::marker::PhantomData;
use uuid::Uuid;
mod bundle;
mod loader;
mod syste... |
//! An orbit controls plugin for bevy.
//!
//! To control the camera, drag the mouse. The left button rotates. The wheel
//! zooms.
//!
//! ## Usage
//!
//! Register the [`OrbitCameraPlugin`], and insert the [`OrbitCamera`] struct
//! into the entity containing the camera.
//!
//! For example, within the startup system... |
use crate::convex_hull_2d::benchmark::run_benchmark;
use crate::geometry::{print_pts, sort_points_by_x, Point};
use std::sync::{Arc, Mutex};
use std::thread;
pub fn convex_hull(mut data: Vec<Point>) -> Vec<Point> {
// sort by x
sort_points_by_x(&mut data);
const SUB_HULL_COUNT: usize = 1200;
let result... |
use std::{fmt, iter};
use num_traits::Zero;
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use engine_shared::{motes::Motes, newtypes::Blake2bHash, transform::TypeMismatch};
use engine_storage::global_state::CommitResult;
use engine_wasm_prep::wasm_costs::WasmCosts;
use types::{account::PublicKe... |
use crate::constants::*;
use crate::structs::libraries::Libraries;
use crate::structs::settings::Profile;
use crate::structs::*;
use crate::utils::files;
use crossbeam_channel::Sender;
use futures::{stream, StreamExt};
use reqwest;
use std::fs::{create_dir_all, File};
use std::io::Read;
use std::io::{BufRead, BufReader... |
// Copyright 2021MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// https://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or di... |
use crate::event;
use crate::event::Event;
use crate::renderer::{Message, RenderInstruction};
use crate::util::{Queue, Vector2D};
use crate::widget::{Axis, Layout, Widget};
use std::cell::RefCell;
use std::rc::Weak;
/// List is a widget that displays multiple widgets in one column.
#[derive(Clone)]
pub struct SliverV... |
use std::convert::From;
use std::fmt;
#[allow(missing_docs)]
/// Contains a variant for each defined status code according to
/// the spec in: https://datatracker.ietf.org/doc/html/rfc7231#section-6.1.
#[derive(Debug, PartialEq, Eq)]
pub enum StatusCode {
// https://datatracker.ietf.org/doc/html/rfc7231#section-6.... |
// Copyright (c) 2020 <NAME> <<EMAIL>>. All rights reserved.
// Use of this source is governed by Apache-2.0 License that can be found
// in the LICENSE file.
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
pub type c_char = u8;
// First import architecture specific types.
#[cfg(target_arch = "aarch64")]
#... |
use holo_hash::*;
use holochain_sqlite::rusqlite::named_params;
use holochain_types::dht_op::DhtOpType;
use holochain_zome_types::*;
use std::fmt::Debug;
use super::*;
#[derive(Debug, Clone)]
pub struct GetLinksQuery {
query: LinksQuery,
}
#[derive(Debug, Clone)]
pub struct LinksQuery {
pub base: Arc<EntryHa... |
//! Filter functions and abstractions.
//!
//! MiniJinja inherits from Jinja2 the concept of filter functions. These are functions
//! which are applied to values to modify them. For example the expression `{{ 42|filter(23) }}`
//! invokes the filter `filter` with the arguments `42` and `23`.
//!
//! MiniJinja comes ... |
use crate::abstracts::{
AbstractSource,
AbstractBoundary,
ComparableAbstractSource,
AbstractBoundaryCollection
};
use crate::helpers::find_line_ending;
use crate::raw_token::{RawToken, RawTokenInfo};
use crate::special_characters::{NEW_LINE, TAB};
/// Returns the recognized block and the last seen index.
///
/// T... |
use super::Buffer;
mod editing {
use super::*;
use crate::{editor::EditType, selection::Selection};
use xi_rope::Rope;
#[test]
fn is_pristine() {
let mut buffer = Buffer::new("");
buffer.init_content(Rope::from("abc"));
buffer.edit(&[(Selection::caret(0), "d")], EditType::I... |
use crate::lv_core::style::Style;
use crate::Box;
use crate::{Align, LvError, LvResult};
use core::ptr;
/// Represents a native LVGL object
pub trait NativeObject {
/// Provide common way to access to the underlying native object pointer.
fn raw(&self) -> LvResult<ptr::NonNull<lvgl_sys::lv_obj_t>>;
}
/// Gene... |
use iron::prelude::*;
use serde_json::Value;
use common::http::*;
use common::utils::*;
use services::topic::*;
use services::user::get_user_id;
use services::comment::get_last_comment_by_topic_id;
pub fn render_default_topic_list(req: &mut Request) -> IronResult<Response> {
render_topic_list("default", req)
}
... |
//! ICE Candidate (`a=candidate:...`)
use crate::{ice_char, not_whitespace, probe_host6};
use bytes::Bytes;
use bytesstr::BytesStr;
use internal::ws;
use nom::bytes::complete::{tag, take_while, take_while1, take_while_m_n};
use nom::character::complete::digit1;
use nom::combinator::{map, map_res};
use nom::multi::many... |
use crate::data::{Compression, NBTFile, NBT};
use crate::Result;
use std::io::{self, BufRead, Read};
use byteorder::{BigEndian, ReadBytesExt};
use flate2::read::{GzDecoder, ZlibDecoder};
/// Read an NBT file from the given reader
pub fn read_file<R: BufRead>(mut reader: &mut R) -> Result<NBTFile> {
/* Peek into... |
// Copyright 2017-2019 <NAME>. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. T... |
use crate::context::CmpContext;
use crate::context::ValidationContext;
use crate::core::Type;
use crate::core::TypeRef;
use crate::identifier::Identifier;
use crate::metadata::Meta;
use crate::metadata::MetadataSetter;
use crate::metadata::WithMetadata;
use crate::schema_builder::BuildsOwnSchema;
use crate::schema_buil... |
/*
* 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 common::WithLocation;
use graphql_ir::{Argument, ConstantValue, Directive, Value};
use interner::{Intern, StringKey};
use lazy_... |
//! Operators in ErgoTree
use super::expr::Expr;
use crate::has_opcode::HasOpCode;
use crate::serialization::op_code::OpCode;
use crate::types::stype::SType;
extern crate derive_more;
use derive_more::From;
#[cfg(feature = "arbitrary")]
use proptest_derive::Arbitrary;
/// Operations for numerical types
#[derive(Par... |
// Based on the SSPI client example from MSDN: https://docs.microsoft.com/en-us/windows/win32/secauthn/using-sspi-with-a-windows-sockets-client
// This example works with the server example using SSPI. The client and server examples are designed to work together.
// This example demonstrates initializing an authentica... |
// Copyright 2020-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 agr... |
//! An implementation of the [MD4][1] cryptographic hash algorithm.
//!
//! # Usage
//!
//! ```rust
//! use md4::{Md4, Digest};
//! use hex_literal::hex;
//!
//! // create a Md4 hasher instance
//! let mut hasher = Md4::new();
//!
//! // process input message
//! hasher.update(b"hello world");
//!
//! // acquire hash d... |
use std::sync::Arc;
use serde_derive::{Deserialize, Serialize};
use anyhow::Result;
use async_tungstenite::{tokio::accept_async, tungstenite::Message};
use tokio::net::TcpListener;
use futures::{StreamExt, SinkExt};
use futures::prelude::*;
use tokio_rustls::{TlsAcceptor, rustls::NoClientAuth, rustls::{ServerConfig, in... |
mod error;
mod evaluated;
use {
super::{context::FilterContext, select::select},
crate::{
data::{get_name, Value},
result::Result,
store::Store,
},
async_recursion::async_recursion,
futures::stream::{StreamExt, TryStreamExt},
im_rc::HashMap,
sqlparser::ast::{
... |
use std::fmt;
/// paramType represents a SCTP INIT/INITACK parameter
#[derive(Debug, Copy, Clone, PartialEq)]
#[repr(C)]
pub(crate) enum ParamType {
HeartbeatInfo = 1,
/// Heartbeat Info [RFCRFC4960]
Ipv4Addr = 5,
/// IPv4 IP [RFCRFC4960]
Ipv6Addr = 6,
/// IPv6 IP [RFCRFC4960]
StateCookie =... |
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate lazy_static;
use config::{get_config, init_config};
use error::{bail, Context, Error};
use futures::prelude::*;
use hyper::{service::make_service_fn, Server as HttpServer};
use ring::rand::{SecureRandom, SystemRandom};
use... |
///! Integritee worker. Inspiration for this design came from parity's substrate Client.
///
/// This should serve as a proof of concept for a potential refactoring design. Ultimately, everything
/// from the main.rs should be covered by the worker struct here - hidden and split across
/// multiple traits.
use async_tr... |
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
use std::sync::{atomic::Ordering, Arc};
use std::thread;
use std::time::{Duration, Instant};
use crossbeam_channel::unbounded;
use hashbrown::HashMap;
use parking_lot::Mutex;
use rand::prelude::*;
use rand_distr::Pareto;
mod common;
mod handler;
mod network;
mod utils;
... |
extern crate plank_errors;
extern crate plank_frontend;
extern crate plank_interpreter;
extern crate plank_ir;
extern crate plank_syntax;
mod test_parser;
use plank_errors::reporter::Diagnostic;
use std::fs;
use std::io;
use std::io::prelude::*;
enum BuildError {
Fail(Vec<Diagnostic>),
BadIr(plank_ir::ir::Sy... |
#![allow(dead_code)]
use arch::x86_64::kernel::syscall_handler;
use logging::*;
use scheduler::task::BOOT_STACK;
use x86::controlregs::*;
use x86::cpuid::*;
use x86::io::*;
use x86::msr::*;
// MSR EFER bits
const EFER_SCE: u64 = (1 << 0);
const EFER_LME: u64 = (1 << 8);
const EFER_LMA: u64 = (1 << 10);
const EFER_NXE... |
use crate::{
types::{EthClient, EthSignerMiddleware},
utils::{get_gas_price, get_logic_call_nonce, GasCost},
};
use ethers::contract::builders::ContractCall;
use ethers::prelude::*;
use ethers::types::Address as EthAddress;
use gravity_abi::gravity::*;
use gravity_utils::ethereum::{bytes_to_hex_str, vec_u8_to_f... |
use std::{thread, time::Duration};
use corus::{
contrib::{
controllable_param,
generic_poly_synth::{NoteOff, NoteOn, PolySynth, Voice},
rand_fm_synth::rand_fm_synth,
},
core::{
mul::Mul, var::Var, controllable::Controllable, placeholder::Placeholder, Node,
},
notenum... |
#[macro_use]
extern crate criterion;
extern crate crypto;
extern crate rustc_serialize;
use crate::crypto::symmetriccipher::BlockEncryptor;
use crate::crypto::symmetriccipher::BlockEncryptorX8;
use crate::crypto::buffer::WriteBuffer;
use crate::crypto::buffer::ReadBuffer;
use crypto::aes::{self, KeySize};
use crypto::... |
//! Internal API used to identify the type of cartridge that was loaded by examining the header.
use num_enum::TryFromPrimitive;
use std::convert::TryFrom;
pub struct CartridgeDesc<'a>(&'a [u8]);
impl CartridgeDesc<'_> {
/// The cartridge header sits at bytes 0x100..=0x14F
pub fn from_header(header: &[u8]) -... |
use axum::{
extract::{Extension, Query},
http::StatusCode,
response::{IntoResponse, Redirect},
routing::get,
Json, Router,
};
use serde::Deserialize;
use std::net::SocketAddr;
use std::sync::{Arc, Mutex};
use tower_http::trace::TraceLayer;
use tracing_subscriber::prelude::*;
use twitter_v2::authori... |
use interaction::{Interaction, InteractionBuilder};
use qust::command;
use qust::command::ENABLE_COMMANDS;
use std::env;
use std::env::args;
use std::io;
use std::io::{Read, Write};
use std::net::{SocketAddr, TcpStream};
use std::path::PathBuf;
use std::process::exit;
use std::str::from_utf8;
const HOST: &str = "127.0... |
extern crate serde;
#[macro_use] extern crate serde_derive;
#[cfg(test)] #[macro_use] extern crate serde_json;
#[cfg(not(test))] extern crate serde_json;
/// The structure of the `Term` enum is symmetric to the representation of the
/// parsed JSON structure that we want to fullfil the contract of the parser.
///
/// ... |
#[cfg(test)]
static mut _COUNT: u128 = 0;
static _STEP: u128 = 10;
#[cfg(any(feature = "parallel"))]
static _NUM_AGENT: u32 = 10;
#[cfg(any(feature = "parallel"))]
use {
crate::model::flockers::{bird::*, state::*},
rust_ab::engine::location::Real2D,
// rust_ab::engine::schedule::Schedule,
rust_ab::eng... |
use std::io;
use std::path::{Path, PathBuf};
use std::sync::{Arc};
use std::str::from_utf8;
use std::time::{SystemTime, Duration};
use http_file_headers::{Input as HeadersInput, Output};
use httpdate::HttpDate;
use tk_http::Status;
use config::static_files::{VersionChars, VersionedStatic};
use default_error_page::{er... |
//! Activate units (recursively and parallel along the dependency tree)
use super::units::*;
use crate::platform::EventFd;
use std::collections::HashMap;
use std::sync::Arc;
use threadpool::ThreadPool;
fn activate_units_recursive(
ids_to_start: Vec<UnitId>,
run_info: ArcRuntimeInfo,
tpool: ThreadPool,
... |
use criterion::{
black_box, criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion,
PlotConfiguration,
};
use linfa::traits::{IncrementalFit, Transformer};
use linfa::DatasetBase;
use linfa_clustering::{generate_blobs, KMeans, KMeansInit};
use ndarray::Array2;
use ndarray_rand::RandomExt;
use ndarra... |
use std::fmt::Write;
use std::str::FromStr;
use super::super::TraitHandler;
use super::models::{FieldAttributeBuilder, TypeAttributeBuilder};
use crate::panic;
use crate::Trait;
use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use syn::{Data, DeriveInput, Fields, Generics, Lit, Meta};
pub struct DefaultE... |
//! Internal helper functions and types
use log::info;
use rayon::prelude::*;
use std::cell::UnsafeCell;
/// Macro version of Option::map that allows using e.g. using the ?-operator in the map expression
///
/// For example:
/// ```
/// let four: f64 = map_option!(Some(2.0_f64), val => val? * 2.0);
/// ```
macro_rule... |
use crate::{
layout::{CellDirection, CellSize, StripLayout},
sizing::Sizing,
Size,
};
use egui::{Response, Ui};
/// Builder for creating a new [`Strip`].
///
/// This can be used to do dynamic layouts.
///
/// In contrast to normal egui behavior, strip cells do *not* grow with its children!
///
/// First u... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.