all of the things
rodzic
53f37635b2
commit
df68efdea8
|
@ -45,3 +45,15 @@ $RECYCLE.BIN/
|
|||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
|
||||
#Added by cargo
|
||||
#
|
||||
#already existing elements are commented out
|
||||
|
||||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
|
||||
|
||||
**/target
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "Chapter10/rusty-ml/fashion-mnist"]
|
||||
path = Chapter10/rusty-ml/fashion-mnist
|
||||
url = https://github.com/zalandoresearch/fashion-mnist.git
|
|
@ -1 +0,0 @@
|
|||
{"rustc_fingerprint":2823603757898662870,"outputs":{"6217262102979750783":["___.wasm\nlib___.rlib\n___.wasm\nlib___.a\n/home/cm/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"wasm32\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"cas\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"unknown\"\ntarget_pointer_width=\"32\"\ntarget_vendor=\"unknown\"\n","warning: dropping unsupported crate type `dylib` for target `wasm32-unknown-unknown`\n\nwarning: dropping unsupported crate type `proc-macro` for target `wasm32-unknown-unknown`\n\n"],"1617349019360157463":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/cm/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"mmx\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"cas\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"unknown\"\nunix\n",""],"1164083562126845933":["rustc 1.35.0-nightly (aa99abeb2 2019-04-14)\nbinary: rustc\ncommit-hash: aa99abeb262307d5e9aa11a792312fd620b7f89a\ncommit-date: 2019-04-14\nhost: x86_64-unknown-linux-gnu\nrelease: 1.35.0-nightly\nLLVM version: 8.0\n",""]},"successes":{}}
|
|
@ -1 +0,0 @@
|
|||
6103dbe66b1c1499
|
|
@ -1 +0,0 @@
|
|||
{"rustc":6657857933646595371,"features":"[]","target":8081900203599542089,"profile":14996655781355331481,"path":1036222786711178230,"deps":[],"local":[{"MtimeBased":[[1555702721,688522520],"/home/cm/workspace/Mine/Rust-Cookbook/Chapter03/custom-build/out/wasm32-unknown-unknown/debug/.fingerprint/custom-build-0354a0e8029ace12/dep-bin-custom-build"]}],"rustflags":[],"metadata":14007051628862413002}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
This file has an mtime of when this was started.
|
|
@ -1 +0,0 @@
|
|||
/home/cm/workspace/Mine/Rust-Cookbook/Chapter03/custom-build/out/wasm32-unknown-unknown/debug/custom-build.wasm: /home/cm/workspace/Mine/Rust-Cookbook/Chapter03/custom-build/src/main.rs
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
@ -1,5 +0,0 @@
|
|||
/home/cm/workspace/Mine/Rust-Cookbook/Chapter03/custom-build/out/wasm32-unknown-unknown/debug/deps/custom_build.wasm: src/main.rs
|
||||
|
||||
/home/cm/workspace/Mine/Rust-Cookbook/Chapter03/custom-build/out/wasm32-unknown-unknown/debug/deps/custom_build.d: src/main.rs
|
||||
|
||||
src/main.rs:
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
dfc8789243e23ada
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":2822179955554191932,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.5.3"]},"features":"None","deps":[["memchr v0.1.11",9796655647945095179]],"rustflags":[]}
|
|
@ -1 +0,0 @@
|
|||
7cded6463fd5eade
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":2983294961366240915,"profile":11154289914177168617,"local":{"variant":"MtimeBased","fields":[[1486962385,354966260],[47,104,111,109,101,47,118,105,107,105,47,114,117,115,116,95,99,111,111,107,98,111,111,107,47,99,104,97,112,116,101,114,51,47,104,101,108,108,111,95,119,111,114,108,100,47,116,97,114,103,101,116,47,100,101,98,117,103,47,46,102,105,110,103,101,114,112,114,105,110,116,47,104,101,108,108,111,95,119,111,114,108,100,45,54,51,102,101,98,98,54,102,55,101,48,101,52,102,52,52,47,100,101,112,45,98,105,110,45,104,101,108,108,111,95,119,111,114,108,100]]},"features":"None","deps":[["rand v0.3.14 (https://github.com/rust-lang-nursery/rand.git?rev=9f35b8e#9f35b8e4)",13226203809758372760],["regex v0.1.80",1978488238110420625],["time v0.1.36",1283136440624876714]],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
1cf3f950c7134396
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":2983294961366240915,"profile":14216767367406228602,"local":{"variant":"MtimeBased","fields":[[1486962612,514974731],[47,104,111,109,101,47,118,105,107,105,47,114,117,115,116,95,99,111,111,107,98,111,111,107,47,99,104,97,112,116,101,114,51,47,104,101,108,108,111,95,119,111,114,108,100,47,116,97,114,103,101,116,47,100,101,98,117,103,47,46,102,105,110,103,101,114,112,114,105,110,116,47,104,101,108,108,111,95,119,111,114,108,100,45,54,51,102,101,98,98,54,102,55,101,48,101,52,102,52,52,47,100,101,112,45,116,101,115,116,45,98,105,110,45,104,101,108,108,111,95,119,111,114,108,100]]},"features":"None","deps":[["rand v0.3.14 (https://github.com/rust-lang-nursery/rand.git?rev=9f35b8e#9f35b8e4)",13226203809758372760],["regex v0.1.80",1978488238110420625],["time v0.1.36",1283136440624876714]],"rustflags":[]}
|
|
@ -1 +0,0 @@
|
|||
d1a1cce467c66d55
|
|
@ -1 +0,0 @@
|
|||
1fafa3e3cb7e026f
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":4086851835445132369,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.2.2"]},"features":"None","deps":[["winapi-build v0.1.1",17837523682249557571]],"rustflags":[]}
|
|
@ -1 +0,0 @@
|
|||
{"rustc":0,"target":0,"profile":0,"local":{"variant":"Precalculated","fields":["0.2.2"]},"features":"","deps":[],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
a4afa36e230ccdcf
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":6026625737212813429,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.2.2"]},"features":"None","deps":[["winapi v0.2.8",8159171814049759188]],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
00b3ce50ff4e2fa3
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":12975131716389151093,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.2.20"]},"features":"Some([\"default\", \"use_std\"])","deps":[],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
0b78972a68b6f487
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":15077895593472080321,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.1.11"]},"features":"None","deps":[["libc v0.2.20",11758704010567004928]],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
98e3901f4aea8cb7
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":9445322636251195083,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["9f35b8e439eeedd60b9414c58f389bdc6a3284f9"]},"features":"None","deps":[["libc v0.2.20",11758704010567004928]],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
912edcf09100751b
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":12670156471944522085,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.1.80"]},"features":"None","deps":[["aho-corasick v0.5.3",15725129828765583583],["memchr v0.1.11",9796655647945095179],["regex-syntax v0.3.9",2097099445182631133],["thread_local v0.2.7",18134237447290576221],["utf8-ranges v0.1.3",13231105802975277104]],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
dd8cc7a0d5641a1d
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":16088928192531196849,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.3.9"]},"features":"None","deps":[],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
9e46f94439dcd8c5
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":12631885209046341097,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["2.0.0"]},"features":"None","deps":[["kernel32-sys v0.2.2",14973637682396376996],["libc v0.2.20",11758704010567004928]],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
5d5d5706e1c0a9fb
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":12399525229491177571,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.2.7"]},"features":"None","deps":[["thread-id v2.0.0",14256386758969738910]],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
aa0cce5dcb9dce11
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":593786052017149270,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.1.36"]},"features":"None","deps":[["libc v0.2.20",11758704010567004928]],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
3070f35ba0549eb7
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":17624444246549344061,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.1.3"]},"features":"None","deps":[],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
d4bfd02589333b71
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":7062486825205066367,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.2.8"]},"features":"None","deps":[],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
|
@ -1 +0,0 @@
|
|||
43461a21489d8bf7
|
|
@ -1 +0,0 @@
|
|||
{"rustc":16218068117412374134,"target":3649318858816229980,"profile":11154289914177168617,"local":{"variant":"Precalculated","fields":["0.1.1"]},"features":"None","deps":[],"rustflags":[]}
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
@ -5,5 +5,5 @@ authors = ["Claus Matzinger <claus.matzinger+kb@gmail.com>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "0.1", features = ["async-await-preview"] }
|
||||
hyper = "0.12"
|
||||
runtime = "0.3.0-alpha.6"
|
||||
surf = "1.0"
|
||||
|
|
|
@ -1,22 +1,15 @@
|
|||
#![feature(await_macro, async_await)]
|
||||
use surf::Exception;
|
||||
use surf::http::StatusCode;
|
||||
|
||||
use tokio::await;
|
||||
use tokio::prelude::*;
|
||||
use hyper::{Client, StatusCode};
|
||||
use std::time::Duration;
|
||||
use std::str;
|
||||
|
||||
async fn response_code(url: &str) -> StatusCode {
|
||||
let uri = url.parse().unwrap();
|
||||
let client = Client::new();
|
||||
let response = await!(client.get(uri)
|
||||
.timeout(Duration::from_secs(30))).unwrap();
|
||||
response.status()
|
||||
async fn response_code(url: &str) -> Result<StatusCode, Exception> {
|
||||
let res = surf::get(url).await?;
|
||||
Ok(res.status())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
tokio::run_async(async {
|
||||
let status = await!(response_code("http://blog.x5ff.xyz"));
|
||||
println!("Got the status: {}", status);
|
||||
});
|
||||
#[runtime::main]
|
||||
async fn main() -> Result<(), Exception> {
|
||||
let url = "https://www.rust-lang.org";
|
||||
let status = response_code(url).await?;
|
||||
println!("{} responded with HTTP {}", url, status);
|
||||
Ok(())
|
||||
}
|
|
@ -10,10 +10,10 @@ crate-type = ["cdylib"]
|
|||
|
||||
[dependencies]
|
||||
sha2 = "0.8"
|
||||
wasm-bindgen = "0.2.47"
|
||||
wasm-bindgen = "0.2.48"
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3.4"
|
||||
version = "0.3.25"
|
||||
features = [
|
||||
'Document',
|
||||
'Element',
|
||||
|
|
|
@ -26,14 +26,17 @@ pub fn start() -> Result<(), JsValue> {
|
|||
|
||||
#[wasm_bindgen]
|
||||
pub extern "C" fn digest_attach(data: String, elem_id: String) -> Result<(), JsValue> {
|
||||
let window = web_sys::window().expect("no global `window` exists");
|
||||
let document = window.document().expect("should have a document on window");
|
||||
//let body = document.body().expect("document should have a body");
|
||||
|
||||
// Manufacture the element we're gonna append
|
||||
let val = document.get_element_by_id(&elem_id).expect(&format!("Could not get element with id '{}'", elem_id));
|
||||
let signature = hex_digest(&data);
|
||||
val.set_inner_html(&signature);
|
||||
Ok(())
|
||||
web_sys::window().map_or(Err("No window found".into()), |win| {
|
||||
if let Some(doc) = win.document() {
|
||||
doc.get_element_by_id(&elem_id).map_or(Err(format!("No element with id {} found", elem_id).into()), |val|{
|
||||
let signature = hex_digest(&data);
|
||||
val.set_inner_html(&signature);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
else {
|
||||
Err("No document found".into())
|
||||
}
|
||||
})
|
||||
}
|
||||
// No tests :(
|
|
@ -1,3 +1,25 @@
|
|||
#[cfg(target_arch = "x86")]
|
||||
const ARCH: &str = "x86";
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
const ARCH: &str = "x64";
|
||||
|
||||
#[cfg(target_arch = "mips")]
|
||||
const ARCH: &str = "mips";
|
||||
|
||||
#[cfg(target_arch = "powerpc")]
|
||||
const ARCH: &str = "powerpc";
|
||||
|
||||
#[cfg(target_arch = "powerpc64")]
|
||||
const ARCH: &str = "powerpc64";
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
const ARCH: &str = "ARM";
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
const ARCH: &str = "ARM64";
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
println!("Compiled for {}", ARCH);
|
||||
}
|
||||
|
|
|
@ -7,3 +7,4 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.5"
|
|
@ -1,3 +1,16 @@
|
|||
|
||||
mod sensor;
|
||||
|
||||
use sensor::{Bmx42Device, RawI2CDeviceMock, Thermometer};
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
let mut device = Bmx42Device::new(RawI2CDeviceMock::new("/dev/i2c-1".into(), 0x5f)).unwrap();
|
||||
let pause = Duration::from_secs(1);
|
||||
loop {
|
||||
println!("Current temperature {} °C", device.temp_celsius().unwrap());
|
||||
sleep(pause);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
use std::io;
|
||||
use rand::prelude::*;
|
||||
|
||||
pub trait Thermometer {
|
||||
fn temp_celsius(&mut self) -> Result<f32>;
|
||||
}
|
||||
|
||||
type Result<T> = std::result::Result<T, io::Error>;
|
||||
|
||||
enum Register {
|
||||
Calib0 = 0x00,
|
||||
Data = 0x01,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct RawI2CDeviceMock {
|
||||
path: String,
|
||||
device_id: u8,
|
||||
}
|
||||
|
||||
|
||||
impl RawI2CDeviceMock {
|
||||
pub fn new(path: String, device_id: u8) -> RawI2CDeviceMock {
|
||||
RawI2CDeviceMock {
|
||||
path: path,
|
||||
device_id: device_id,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read(&self, register: u8) -> Result<u8> {
|
||||
let register = register as usize;
|
||||
if register == Register::Calib0 as usize {
|
||||
Ok(1_u8)
|
||||
} else { // register is the data register
|
||||
Ok(random::<u8>())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Bmx42Device {
|
||||
raw: RawI2CDeviceMock,
|
||||
calibration: u8,
|
||||
}
|
||||
|
||||
impl Bmx42Device {
|
||||
pub fn new(device: RawI2CDeviceMock) -> Result<Bmx42Device> {
|
||||
let calib = device.read(Register::Calib0 as u8)?;
|
||||
Ok(Bmx42Device {
|
||||
raw: device,
|
||||
calibration: calib
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Thermometer for Bmx42Device {
|
||||
fn temp_celsius(&mut self) -> Result<f32> {
|
||||
let raw_temp = self.raw.read(Register::Data as u8)?;
|
||||
// converts the result into something usable; from the specification
|
||||
Ok(((raw_temp as i8) << (self.calibration as i8)) as f32 / 10.0)
|
||||
}
|
||||
}
|
|
@ -7,3 +7,6 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tokio = "0.1"
|
||||
tokio-timer = "0.2"
|
||||
rand = "0.5"
|
Some files were not shown because too many files have changed in this diff Show More
Ładowanie…
Reference in New Issue