text
stringlengths
8
4.13M
mod http; mod server; mod storage; pub use crate::server::Server; pub use crate::storage::{ dynamo_db_driver::DynamoDbDriver, storage_actor::StorageExecutor, storage_driver::{StorageCmd, StorageDriver}, };
//! Host I/O use core::{fmt, slice}; use core::fmt::Write; /// File descriptors const STDOUT: usize = 1; const STDERR: usize = 2; /// Host's standard error struct Stderr; /// Host's standard output struct Stdout; fn write_all(fd: usize, mut buffer: &[u8]) { while !buffer.is_empty() { match unsafe { sys...
mod binary; pub use binary::MemcacheBinary as Memcache;
use std::sync::Arc; use axum::{ extract::{Path, State}, http::StatusCode, response::{IntoResponse, Redirect, Response}, }; use maud::{html, Markup}; use rss::validation::Validate; use tracing::instrument; use crate::{ http_server::{ pages::blog::md::IntoHtml, templates::{base_constrai...
use chrono::{Datelike, Local, TimeZone}; use serde::{Deserialize, Serialize}; use std::fs::File; use std::io::Write; #[derive(Deserialize, Serialize)] pub struct Stat<T> { pub value: T, pub weight: f32, } #[derive(Deserialize, Serialize)] pub struct Stats { pub first_online: u64, pub region: String, ...
use ipfs::{Ipfs, IpfsOptions, IpfsPath, PeerId, TestTypes}; use futures::{FutureExt, TryFutureExt}; fn main() { let options = IpfsOptions::<TestTypes>::default(); env_logger::Builder::new().parse_filters(&options.ipfs_log).init(); tokio::runtime::current_thread::block_on_all(async move { // Start ...
use crate::error::NiaServerResult; use crate::protocol::{NiaConvertable, NiaKey, Serializable}; #[derive(Clone, Debug, Eq)] pub struct NiaKeyChord { modifiers: Vec<NiaKey>, ordinary_key: NiaKey, } impl PartialEq for NiaKeyChord { fn eq(&self, other: &Self) -> bool { if self.ordinary_key != other.o...
use serde::ser::{SerializeStruct, SerializeStructVariant, SerializeTupleVariant}; use serde::Serialize; use crate::Element; use crate::error::TychoError; use crate::serde::ser::seq::SeqSerializer; use crate::serde::ser::struct_::StructSerializer; pub struct VariantSeqSerializer { name: String, seq: SeqSeriali...
use std::fs::File; use std::io::Read; use std::path::PathBuf; use walkdir::WalkDir; /// Find *.rs recursively pub fn find_rust_files(rust_path: &str) -> Vec<PathBuf> { WalkDir::new(rust_path) .into_iter() .filter_map(|e| e.ok()) .filter(|e| { e.file_type().is_file() ...
use crate::common::{ Opcode, Opmode, OPMODES, Closure, Value }; pub fn get_op(i: u32) -> Opcode { Opcode::from((i >> 26 & 0x3F) as u8) } pub fn get_a_mode(i: u32) -> u8 { (i >> 25 & 0x1) as u8 } pub fn get_a(i: u32) -> u8 { (i >> 17 & 0xFF) as u8 } pub fn get_b_mode(i: u32) -> u8 { (i >> 16 & 0x1) as u8 } ...
extern crate sdl; use std::num::Wrapping; use modulo::Mod; use rand::rngs::SmallRng; use rand::{Rng, SeedableRng}; use sdl::event::Event; use retrofw2_rust::controls::*; use retrofw2_rust::geom::Painter; struct Asteroids { screen: sdl::video::Surface, video_info: sdl::video::VideoInfo, height: isize, ...
// Copyright 2019-2020 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate 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 your option) a...
use std::convert::From; use std::fmt::{self, Display}; use std::sync::Arc; use async_trait::async_trait; use failure::Fallible; use http::header::{self, AUTHORIZATION}; use reqwest::Client; use serde::Serialize; use slog_scope::{error, info}; use crate::components::access_token_provider::{self, AccessTokenProvider}; ...
pub mod http; pub mod tpl;
use crate::{AccountName, NumBytes, Read, ScopeName, TableName, Write}; use std::marker::PhantomData; /// TODO docs pub trait Table: Sized { /// TODO docs const NAME: u64; /// TODO docs type Row: Read + Write + NumBytes; /// TODO docs fn primary_key(row: &Self::Row) -> u64; /// TODO docs ...
#[doc = "Register `SDMMC_ICR` reader"] pub type R = crate::R<SDMMC_ICR_SPEC>; #[doc = "Register `SDMMC_ICR` writer"] pub type W = crate::W<SDMMC_ICR_SPEC>; #[doc = "Field `CCRCFAILC` reader - CCRCFAIL flag clear bit Set by software to clear the CCRCFAIL flag."] pub type CCRCFAILC_R = crate::BitReader; #[doc = "Field `C...
use std::io::{self, prelude::*}; use std::collections::BinaryHeap; use std::error::Error; use std::collections::BinaryHeap; /* - read grid - fill max-heap "peaks" with: [val, i, j] for val > 1 - while heap, pop "me": if my value in my cell is larger than me, ignore; since Ive already been dequeued ...
pub use rustc_serialize::json::{Json, ToJson, decode}; pub use super::{Validator, ValidateResult, ValidateResults}; pub use super::{BaseDataMap, BaseDataMapDecoder}; pub use super::{ConnectionPool, InsertResult}; pub mod pages; mod pages_test;
use std::fmt; use lval::LVal; use lenv::LEnv; #[derive(PartialEq)] enum ArithmeticOp { ADD, SUB, MUL, DIV, MOD, MIN, MAX } impl fmt::Display for ArithmeticOp { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use self::ArithmeticOp::*; match *self { ADD ...
use core::time::Duration; use fastping_rs::PingResult::{Idle, Receive}; use influent::measurement::{Measurement, Value}; #[derive(Debug)] pub struct PingResult { rtt: Duration, loss: f32 } impl PingResult { pub fn new() -> PingResult { PingResult { rtt: Duration::from_millis(0), loss: 0.0 } } ...
use crate::components; use anyhow::Result; use maud::{html, Markup, PreEscaped}; use rustimate_service::{RequestContext, Router}; pub(crate) fn page(ctx: &RequestContext, router: &dyn Router, title: &str, content: &Markup) -> Result<Markup> { Ok(html! { (PreEscaped("<!DOCTYPE html>")) html lang="en" { ...
use std::cmp::min; use std::vec::Vec; /// Uses row major layout. pub struct Matrix2d<TNode> { rows: usize, cols: usize, length: usize, nodes: Vec<TNode>, } impl<TNode> Matrix2d<TNode> { /// Used to create a matrix of the specified size. /// #arguments /// * `rows` - The number of rows in t...
//! Serializing Rust data types into CDR. use std::{self, io::Write, marker::PhantomData}; use byteorder::{ByteOrder, WriteBytesExt}; use serde::ser; use crate::{ error::{Error, Result}, size::{calc_serialized_data_size, calc_serialized_data_size_bounded, Infinite, SizeLimit}, }; /// A serializer that write...
pub const HELP_MSG: &str = "\nYou can check help page: https://github.com/ivan770/ares/wiki/Help";
use iced_graphics::Primitive; use iced_native::{ Color as GraphicsColor, Font, HorizontalAlignment, Point, Rectangle, Size, VerticalAlignment, }; use super::Rect; use crate::cssom::Color; use crate::layout::font as layout_font; pub fn create_text( content: String, color: Color, rect: Rect, font: l...
// // Part of Roadkill Project. // // Copyright 2010-2018, Berkus <berkus+github@metta.systems> // // Distributed under the Boost Software License, Version 1.0. // (See file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt) // pub mod support; #[cfg(feature = "convert")] use crate::support::texture::P...
mod hm_tools; use hm_tools::{tools, art}; use std::io; fn main() { std::process::Command::new("clear").status().unwrap(); println!("Welcome to Hangman Official Terminal Game 1978 Copyright, all Right Reserved"); start(); } fn start() { let mut mistakes = 0; let secret = tools::random_word(); ...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// SloWidgetDefinition : Use the SLO and uptime widget to track your SLOs (Service Level Objectives) an...
use crate::leet_code::common::chain_table::ListNode; pub fn main() { let list = ListNode::produce_chain(vec![1, 3, 2]); let reverse_list = Solution::reverse_list(list); println!("{:?}", reverse_list); } struct Solution; impl Solution { pub fn reverse_list(head: Option<Box<ListNode>>) -> Option<Box<Li...
use byteorder::{ByteOrder, LittleEndian}; use libmdbx::*; use tempfile::tempdir; type Database = libmdbx::Database<NoWriteMap>; #[test] fn test_open() { let dir = tempdir().unwrap(); // opening non-existent database with read-only should fail assert!(Database::new() .set_flags(Mode::ReadOnly.into...
#![allow(unused_variables)] use crate::scene::Scene; use crate::spawns::Spawn; use crate::types::System; use super::components::*; pub struct MoveSystem; impl System<GameObject> for MoveSystem { fn requirements(&self, target: &GameObject) -> bool { target.has_position() && target.has_movement...
#[macro_use] extern crate specs_derive; #[macro_use] extern crate shred_derive; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; extern crate airmash_server; extern crate fnv; extern crate htmlescape; extern crate rand; extern crate shred; extern crate shrev; extern crate simple_logger; extern cra...
#[doc = "Register `PUCRF` reader"] pub type R = crate::R<PUCRF_SPEC>; #[doc = "Register `PUCRF` writer"] pub type W = crate::W<PUCRF_SPEC>; #[doc = "Field `PU2` reader - Port F pull-up bit i (i = 2 to 0) Setting PUi bit while the corresponding PDi bit is zero and the APC bit of the PWR_CR3 register is set activates a p...
pub mod data_loader; pub mod input; pub mod models; pub mod mutation; pub mod query; pub mod utils; use crate::db::MysqlPooledConnection; use std::sync::{Arc, Mutex}; //use std::error::Error; use crate::errors::ServiceError; use crate::graphql::data_loader::user::{UserByIdDataLoader, UserDataLoaderBatchById}; use crate...
fn print_double(mut x: f64) { x *= 2.; print!("{}", x); } fn main() { let x = 4.; print_double(x); println!(" {}", x); }
use diesel::backend::Backend; use diesel::deserialize::{self, FromSql}; use diesel::prelude::*; use diesel::serialize::{self, Output, ToSql}; use diesel::sql_types::*; use std::io; use uuid::Uuid; use crate::core::schema::account; use crate::core::{generate_uuid, DbConnection, Money, ServiceError, ServiceResult}; ///...
// This file is part of Substrate. // Copyright (C) 2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://...
use raylib::prelude::*; use specs::prelude::*; use std::sync::{Arc, Mutex}; pub struct ModelComponent { pub model : Model, } unsafe impl Send for ModelComponent{} unsafe impl Sync for ModelComponent{} impl Component for ModelComponent { type Storage = VecStorage<Self>; } struct CameraComponent { camera ...
fn make_change(coins: &[usize], cents: usize) -> usize { let size = cents + 1; let mut ways = vec![0; size]; ways[0] = 1; for &coin in coins { for amount in coin..size { ways[amount] += ways[amount - coin]; } } ways[cents] } fn main() { println!("{}", make_chang...
use vek::Vec2; use specs::prelude::*; use crate::components::*; pub struct Physics; impl<'a> System<'a> for Physics { type SystemData = (WriteStorage<'a, Position>, ReadStorage<'a, Velocity>); fn run(&mut self, (mut positions, velocities): Self::SystemData) { for (Position(pos), vel) in (&mut positi...
use crate::RrtVec3::Vec3; pub fn write_color(v: Vec3) { println!("{} {} {}", (255.999 * v.x()) as i64, (255.999 * v.y()) as i64, (255.999 * v.z()) as i64); }
pub struct Primes { previous: Vec<usize>, } impl Primes { pub fn new() -> Primes { Primes{ previous: Vec::new() } } } impl Iterator for Primes { type Item = usize; fn next(&mut self) -> Option<usize> { let start = match self.previous.last() { Some(&n) => n+1, ...
use serde::{Deserialize, Serialize}; use super::category_taxonomy; use super::{content, publisher}; use crate::openrtb3::bool; #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct App { id: Option<String>, name: Option<String>, #[serde(rename = "pub")] publisher: Option<publisher::Publisher>...
use actix_cors::Cors; use actix_web::{web, App, HttpServer}; use config::Config; use std::collections::HashMap; mod order; mod utils; pub const ADDR: &str = "0.0.0.0:8004"; lazy_static::lazy_static! { static ref SECRETS: HashMap<String, String> = { let mut config = Config::default(); config.merge(config::File::wi...
extern crate rand; extern crate sarkara; use rand::{thread_rng, Rng, ThreadRng}; use sarkara::aead::AeadCipher; use sarkara::kex::KeyExchange; use sarkara::sealedbox::SealedBox; use sarkara::kex::kyber::Kyber; use sarkara::aead::sparx256colm0::Sparx256Colm0; use sarkara::aead::norx6441::Norx; fn test_sealedbox<K: Ke...
use select::predicate::*; use select::document::Document; use regex::Regex; use std::fs::File; use std::io::BufReader; /// Reads in an html document from `in_file`, removes html tags, optionally does /// case folding and punctuation stripping, writing result file to `out_file`. pub fn parse(in_file: File, case_fold: ...
use log::{debug, error, info, trace}; use super::*; use crate::db; use crate::prelude::*; use dotenv::dotenv; use postgres::{Connection, TlsMode}; use rayon::prelude::*; use std::collections::{HashMap, HashSet}; use std::sync::{Arc, Mutex}; use std::time::Instant; use std::{env, fmt::Write}; pub fn establish_connecti...
#[doc = "Register `K2LR` writer"] pub type W = crate::W<K2LR_SPEC>; #[doc = "Field `k` writer - k96"] pub type K_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 31, O, u32>; #[doc = "Field `b121` writer - b121"] pub type B121_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; impl W { #[doc = "Bits 0:30 ...
#[doc = "Register `SCSR` reader"] pub type R = crate::R<SCSR_SPEC>; #[doc = "Register `SCSR` writer"] pub type W = crate::W<SCSR_SPEC>; #[doc = "Field `SRAM2ER` reader - SRAM2 erase"] pub type SRAM2ER_R = crate::BitReader<SRAM2ERW_A>; #[doc = "SRAM2 erase\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq, E...
// Built-In Attributes #![no_std] // Imports extern crate eng_wasm; extern crate eng_wasm_derive; extern crate serde; use eng_wasm::*; use eng_wasm_derive::pub_interface; use serde::{Serialize, Deserialize}; // Encrypted state keys static PARTICIPANTS: &str = "participants"; // Structs #[derive(Serialize, Deseriali...
//! The RFC 959 Data Port (`PORT`) command // // The argument is a HOST-PORT specification for the data port // to be used in data connection. There are defaults for both // the user and server data ports, and under normal // circumstances this command and its reply are not needed. If // this command is used, the arg...
use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn main() { let mut elements = [0; 1000]; let mut index = 0; // File hosts must exist in current path before this produces output if let Ok(lines) = read_lines("input") { // Consumes the iterator, returns an (Optional) Strin...
#[macro_use] extern crate dotenv_codegen; extern crate diesel_derive_enum; extern crate itertools; extern crate juniper; use ::mystore_lib::db_connection::establish_connection; use actix_cors::Cors; use actix_identity::{CookieIdentityPolicy, IdentityService}; use actix_web::http::header; use actix_web::middleware::Log...
mod example; use crate::ExampleContainer; use example::*; use yew::prelude::*; use yewprint::{HtmlSelect, Intent, H1, H5}; pub struct SpinnerDoc { callback: Callback<ExampleProps>, state: ExampleProps, } impl Component for SpinnerDoc { type Message = ExampleProps; type Properties = (); fn create...
#[doc = "Register `AHB2RSTR` reader"] pub type R = crate::R<AHB2RSTR_SPEC>; #[doc = "Register `AHB2RSTR` writer"] pub type W = crate::W<AHB2RSTR_SPEC>; #[doc = "Field `DCMIRST` reader - Camera interface reset"] pub type DCMIRST_R = crate::BitReader<DCMIRST_A>; #[doc = "Camera interface reset\n\nValue on reset: 0"] #[de...
use std::collections::HashMap; use std::io::Write; use std::path::{Path,PathBuf}; #[derive(Debug)] pub struct Neighborhood<T> { barcodes: Vec<(Vec<u8>, T)> } impl <T> Neighborhood<T> { fn new() -> Self { Neighborhood { barcodes: Vec::new() } } fn insert(&mut self, barc...
//! Temporary files and directories. //! //! - Use the [`tempfile()`] function for temporary files //! - Use the [`tempdir()`] function for temporary directories. //! //! # Design //! //! This crate provides several approaches to creating temporary files and directories. //! [`tempfile()`] relies on the OS to remove th...
use std::{fs::File, io::Write}; /// Testing out the zobrist hashing use pacosako::{zobrist, DenseBoard}; use rand::RngCore; fn main() { let board = DenseBoard::new(); println!("{}", zobrist::fresh_zobrist(&board)); build_file("data/zobrist.txt", 12 * 64 * 2).unwrap(); } pub fn build_file(path: &str, siz...
use rand::{thread_rng, Rng}; use std::time::{Duration, Instant}; /// Make a zero delay backoff pub fn instant() -> impl Backoff + Sized { Duration::from_secs(0) } /// Make a constant duration backoff pub fn constant(duration: Duration) -> impl Backoff + Sized { duration } pub trait Backoff: Send { /// Ge...
#[doc = "Register `NSSR` reader"] pub type R = crate::R<NSSR_SPEC>; #[doc = "Register `NSSR` writer"] pub type W = crate::W<NSSR_SPEC>; #[doc = "Field `NSEOP` reader - NSEOP"] pub type NSEOP_R = crate::BitReader; #[doc = "Field `NSEOP` writer - NSEOP"] pub type NSEOP_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, ...
//! Reset and Clock Control #![deny(missing_docs)] use crate::pwr::VoltageScale as Voltage; use crate::stm32::rcc::cfgr::SW_A as SW; use crate::stm32::rcc::cfgr::TIMPRE_A as TIMPRE; use crate::stm32::rcc::d1ccipr::CKPERSEL_A as CKPERSEL; use crate::stm32::rcc::d1cfgr::HPRE_A as HPRE; use crate::stm32::rcc::pllckselr::...
//! This example demonstrates using colors to stylize [`Grid`] borders. //! Borders can be set globally with [`SpannedConfig::set_border_color_global()`] //! or individually with [`SpannedConfig::set_border_color()`]. //! //! * 🚩 This example requires the `color` feature. //! //! * [`CompactConfig`] also supports colo...
// (C) Copyright 2019-2020 Hewlett Packard Enterprise Development LP /// The internal Pest parser. #[derive(Parser)] #[grammar = "dockerfile_parser.pest"] pub(crate) struct DockerfileParser; /// A Pest Pair for Dockerfile rules. pub(crate) type Pair<'a> = pest::iterators::Pair<'a, Rule>;
#![doc = "generated by AutoRust 0.1.0"] #![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct RecoverableDatabaseProperties { #[serde(default, skip_serializing_if = "Option::is_none")] pub edition: Opt...
fn factorial(n:usize) -> usize { if n < 1 { 1 } else { factorial(n - 1) * n } } fn main() { println!("factorial(13): {}", factorial(13)); }
use std::fs::File; use std::io; use std::fs; use std::io::Read; use std::io::ErrorKind; use std::error::Error; // Main function can return a Result<T, E> if necessary // Box<dyn Error> is called a "trait object" // Can read this to mean "any kind of error" fn main() -> Result<(), Box<dyn Error>> { // thread 'main...
//! Rejections //! //! Part of the power of the [`Filter`](../trait.Filter.html) system is being able to //! reject a request from a filter chain. This allows for filters to be //! combined with `or`, so that if one side of the chain finds that a request //! doesn't fulfill its requirements, the other side can try to p...
#[macro_use] extern crate serde_derive; #[macro_use] extern crate chan; extern crate chan_signal; extern crate dirs; extern crate notify; extern crate time; extern crate toml; use std::thread; use std::time::Duration; use std::sync::mpsc::{channel, Sender, Receiver, TryRecvError}; use std::fs; use std::path::{Path...
#[doc = "Register `RCC_SPI2S1CKSELR` reader"] pub type R = crate::R<RCC_SPI2S1CKSELR_SPEC>; #[doc = "Register `RCC_SPI2S1CKSELR` writer"] pub type W = crate::W<RCC_SPI2S1CKSELR_SPEC>; #[doc = "Field `SPI1SRC` reader - SPI1SRC"] pub type SPI1SRC_R = crate::FieldReader; #[doc = "Field `SPI1SRC` writer - SPI1SRC"] pub typ...
use std::path::Path; use tar::{Builder, Archive}; use walkdir::WalkDir; use libflate::gzip::{Encoder, Decoder}; use std::io::{Write, Read}; /// this function currently doesn't work hands on write pub fn compress(archive: &Vec<u8>) -> std::io::Result<Vec<u8>> { let mut encoder = Encoder::new(Vec::new())?; print...
use registry_pol::v1::{RegistryValueType, RegistryValue, parse}; static EMPTY_DATA: &[u8] = include_bytes!("../../test-data/Empty.pol"); static MACHINE_REGISTRY_DATA: &[u8] = include_bytes!("../../test-data/Machine-Registry.pol"); static USER_REGISTRY_DATA: &[u8] = include_bytes!("../../test-data/User-Registry.pol");...
use std::{fs, env}; use http::{Request, Uri}; use isahc; use isahc::ResponseExt; use std::path::Path; pub trait AocImplementation<T> { fn start(&self, day: i32) { download_input_file(day); let contents = fs::read_to_string(get_day_filename(day)).expect("Failed to read input file"); let pa...
use crate::database::values::dsl::ExprDb; use super::super::SQLiteDatabase; use nu_engine::CallExt; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, }; use sqlparser::ast::{Expr...
use serde_json::builder::ObjectBuilder; use std::default::Default; use ::model::{ChannelId, RoleId}; pub struct EditMember(pub ObjectBuilder); impl EditMember { pub fn deafen(self, deafen: bool) -> Self { EditMember(self.0.insert("deaf", deafen)) } pub fn mute(self, mute: bool) -> Self { ...
#![cfg_attr(feature="clippy", feature(plugin))] #![cfg_attr(feature="clippy", plugin(clippy))] #![feature(plugin)] #![plugin(rocket_codegen)] extern crate rocket; extern crate hyper; use std::io::Read; use std::sync::RwLock; use rocket::State; use hyper::Client; use hyper::client::Response; struct TLD { tld: Rw...
use super::construct::saca; #[cfg(feature = "pack")] use super::packed_sa::PackedSuffixArray; use super::utils::{lcp, trunc}; #[cfg(feature = "pack")] use std::io::{Read, Result, Write}; use std::ops::Range; #[cfg(feature = "pack")] use std::path::Path; /// Suffix array for searching byte strings. #[derive(Clone)] pub...
use crate::error; use crate::sparse_set::{OldComponent, Pack}; use crate::storage::EntityId; use crate::type_id::TypeId; use crate::view::ViewMut; use alloc::vec::Vec; use core::any::type_name; pub trait Removable { type Out; } /// Removes component from entities. pub trait Remove<T: Removable> { /// Removes ...
use diesel::connection::AnsiTransactionManager; use diesel::pg::Pg; use diesel::Connection; use stq_db::diesel_repo::*; use repos::*; pub trait ReposFactory<C: Connection<Backend = Pg, TransactionManager = AnsiTransactionManager> + 'static>: Clone + Send + Sync + 'static { fn create_pages_repo<'a>(&self, db_c...
#![no_std] use core::panic::PanicInfo; use raspi_pico_sdk::*; #[no_mangle] unsafe fn main() { let led_pin = 25; wrapped_gpio_init(led_pin); wrapped_gpio_set_dir(led_pin, true); loop { wrapped_gpio_put(led_pin, true); wrapped_sleep_ms(250); wrapped_gpio_put(led_pin, false); ...
use chrono::prelude::*; pub fn easter(y: isize, offset: isize) -> Vec<isize> { let a = y % 19; let b = (y as f32 / 100_f32).floor() as isize; let c = y % 100; let d = (b as f32 / 4_f32).floor() as isize; let e = b % 4; let f = ((b + 8) as f32 / 25_f32).floor() as isize; let g = ((b - f + 1)...
//! Cmd arguments // Imports use std::path::PathBuf; /// Arguments #[derive(Clone, Debug)] pub enum Args { /// Serialize to C SerializeC { /// Input file input_file: PathBuf, }, } /// Parses arguments pub fn parse() -> Result<Args, anyhow::Error> { const SERIALIZE_C_SUBCMD: &str = "serialize-c"; const INPUT...
use std::io::{stdin, Read, StdinLock}; use std::str::FromStr; #[allow(dead_code)] struct Scanner<'a> { cin: StdinLock<'a>, } #[allow(dead_code)] impl<'a> Scanner<'a> { fn new(cin: StdinLock<'a>) -> Scanner<'a> { Scanner { cin: cin } } fn read<T: FromStr>(&mut self) -> Option<T> { let t...
// Copyright 2015-2020 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Parity 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 your option) any ...
/* * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you 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.or...
extern crate libc; #[cfg(test)] #[macro_use] extern crate lazy_static; #[cfg(test)] extern crate rand; use std::io::{Read, Write}; use std::net::TcpListener; use std::ffi::CString; mod channel; /// This is a opaque rust equivalent for comedi_t inside libcomedi.h #[allow(non_camel_case_types)] enum comedi_t {} #[l...
/// An enum to represent all characters in the LatinExtendedB block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum LatinExtendedB { /// \u{180}: 'ƀ' LatinSmallLetterBWithStroke, /// \u{181}: 'Ɓ' LatinCapitalLetterBWithHook, /// \u{182}: 'Ƃ' LatinCapitalLetterBWithTopbar, /// \...
// Copyright (c) 2015, <daggerbot@gmail.com> // All rights reserved. use ::display::{ Atom, Display, }; use ::event::{ ClientMessageData, Event, }; #[test] fn test () { // open display let mut display; if let Some(d) = Display::open_default() { display = d; } else { panic!("can't open display...
use serde::{Serialize, Deserialize}; #[derive(Debug, Deserialize)] #[serde(tag = "op")] pub(super) enum ClientMessage { #[serde(rename = "voiceUpdate")] VoiceUpdate(VoiceUpdate), #[serde(rename = "play")] PlayTrack(PlayTrack), #[serde(rename = "stop")] Stop(Stop), #[serde(rename = "seek")] ...
use crate::map::sector::Sector; use crate::map::triangle::Triangle; use crate::math::util::float_eq; use crate::math::util::float_zero; use crate::math::vector::Vector2; use std::cell::RefCell; use std::collections::HashSet; use std::rc::Rc; struct Polygon { index: usize, merge: bool, perimeter: bool, ...
use std::fs::File; use std::io::{BufReader, Cursor, Read}; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::path::Path; use std::time::{Duration, UNIX_EPOCH}; use memmap::Mmap; use errors::Result; use pcap::header::Header as FileHeader; use pcap::packet::Packet as RawPacket; use pcap::Packet; ...
use std::fmt::Debug; use async_trait::async_trait; use bonsaidb_core::{custom_api::CustomApi, permissions::Dispatcher}; use crate::{server::ConnectedClient, CustomServer}; /// Tailors the behavior of a server to your needs. #[async_trait] pub trait Backend: Debug + Send + Sync + Sized + 'static { /// The custom ...
use quote::Tokens; use quote::ToTokens; pub enum Pat { Wild, Ident(&'static str), } impl ToTokens for Pat { fn to_tokens(&self, tokens: &mut Tokens) { match *self { Pat::Wild => { tokens.append("_"); } Pat::Ident(ref ident) => { ...
use std::{ fmt::{Debug, Display}, hint::unreachable_unchecked, str::FromStr, }; use lazy_static::lazy_static; use regex::Regex; use super::Range; #[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct NumberVolume { number: Option<Range>, volume: Option<Range>, } impl FromStr for NumberVolum...
use model::*; use idalloc::IdAlloc; use std; use std::mem; use std::sync::{mpsc, Mutex, Condvar, Arc}; use std::collections::HashMap; use std::any::Any; #[derive(Debug, PartialEq, Eq, Hash)] struct Handle(usize); #[derive(Debug, Clone, PartialEq)] pub struct JustSignal; /// The most basic of changes, which just swa...
//! Gameboard view. use graphics::types::Color; use graphics::{Context, Graphics}; use graphics::character::CharacterCache; use GameboardController; /// Stores gameboard view settings. pub struct GameboardViewSettings { /// Position from left-top corner. pub position: [f64; 2], /// Size of gameboard alon...
use kyoto::data::{ Server, Params }; use kyoto::network::listen::listen; use structopt::StructOpt; /* Main function for kyoto. * Start a webserver to listen to given port and accept new connections. */ pub fn main() -> kyoto::Result<()> { /* Enable logging diagnostics. */ tracing_subscriber::fmt::try_init()?...
/* code copyinspired from: git@github.com:y-stm/rust-iconv.git (witch have a MIT license: https://raw.githubusercontent.com/andelf/rust-iconv/9e2fecaa09c5d1d632fc34b0291d31002f3053c0/Cargo.toml) */ use errno::{errno, Errno}; use libc; use libc::size_t; use log::info; use std::borrow::Cow; use std::error::Error; use std...
//! Synchronization primitives. use core::cell::UnsafeCell; use core::sync::atomic::{self, AtomicBool}; use core::ops; use shim; /// A mutual exclusive container. /// /// This assures that only one holds mutability of the inner value. To get the inner value, you /// need acquire the "lock". If you try to lock it whi...
// // Copyright 2020 The Project Oak 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 required by applicable law o...
use error::{StateError, StateResult}; use fonts::Fonts; use image::Image; use meta::Meta; use project::Project; use state::SiteState; use website::{Website}; pub trait Valid { fn is_valid(&self) -> StateResult; } impl Valid for SiteState { fn is_valid(&self) -> StateResult { if !self.source.exists() ...