error: only the main function can be tagged with #[foob]
--> tests/hello.rs:45:1
|
45 | fn hello() {
| ^^
error: aborting due to previous error
error: Could not compile `runtime`.
To learn more, run the command again with --verbose. [runtime:1]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// required | |
let listener = TcpListener::bind((args.address.as_str(), args.port))?; | |
// what we want to be able to do | |
let listener = TcpListener::bind((&args.address, args.port))?; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set +ex | |
fr() { | |
rg -l "$1" | xargs sed -i "s/$1/$2/g" | |
} | |
# setup | |
fr 'atomic_waker' 'atomic_cx' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/node | |
let dgram = require('dgram') | |
let socket = dgram.createSocket('udp4', (msg, rinfo) => { | |
let peer = `${rinfo.address}:${rinfo.port}` | |
socket.send(msg, peer, (err) => { | |
if (err) peer.close() | |
console.log(`Sent ${rinfo.size} of ${rinfo.size} bytes to ${peer}`) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let config = Config::from_args(); | |
let mut app = tide::App::new(()) | |
.address(config.address) | |
.port(config.port); | |
app.at("/").get(reply); | |
app.serve(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() -> io::Result<()> { | |
executor::block_on(async { | |
let listener = TcpListener::bind(&"127.0.0.1:7878".parse().unwrap())?; | |
let mut incoming = listener.incoming(); | |
while let Some(stream) = await!(incoming.next()) { | |
let stream = stream?; | |
let addr = stream.peer_addr()?; | |
juliex::spawn(async move { | |
let (mut reader, mut writer) = stream.split(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(StructOpt, PartialEq, Debug)] | |
pub struct Cli { | |
bbox_1: u32, | |
bbox_2: u32, | |
bbox_3: u32, | |
bbox_4: u32, | |
} | |
fn main () { | |
let args = Cli::from_args(); |
This is just a thing I've been thinking about for a while, and I'm not sure what the best structure is here. I'd be keen to hear more about examples, literature, and experiences on how people have approached this. I feel it's an important thing to start thinking about early when talking about networking, especially with HTTP/2 & HTTP/3 on the horizon.
Traditional HTTP servers can be expressed as asynchronous transform functions:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use wasm_bindgen::prelude::Closure; | |
use wasm_bindgen::JsCast; | |
use web_sys::{Document, EventTarget}; | |
let document = Document::new().map_err(|_| ErrorKind::Document)?; | |
let target: EventTarget = document.into(); | |
let cb = Closure::wrap(Box::new(move || { | |
println!("hello world from WASM"); | |
}) as Box<Fn()>); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes auto; | |
error_log /var/log/nginx/error.log; | |
pid /run/nginx.pid; | |
include /usr/share/nginx/modules/*.conf; | |
events { | |
worker_connections 1024; | |
} |