rust

Failed to cross-compile library from Windows to Android

别等时光非礼了梦想. 提交于 2021-02-11 07:10:51
问题 I'm trying to cross-compile a Rust library to 4 Android targets (i386, x86_64, armv7, and aarch64) from Windows. I have set up Android NDK toolchain for these targets and tried to compile my library with help of this tutorial. I think I've set up the toolchain correctly, and I'm able to successfully execute aarch64-linux-android-clang in the terminal. Build log: cargo build --target aarch64-linux-android --release --verbose Fresh cc v1.0.28 Fresh autocfg v0.1.1 Fresh version_check v0.1.5

Failed to cross-compile library from Windows to Android

爷,独闯天下 提交于 2021-02-11 07:09:22
问题 I'm trying to cross-compile a Rust library to 4 Android targets (i386, x86_64, armv7, and aarch64) from Windows. I have set up Android NDK toolchain for these targets and tried to compile my library with help of this tutorial. I think I've set up the toolchain correctly, and I'm able to successfully execute aarch64-linux-android-clang in the terminal. Build log: cargo build --target aarch64-linux-android --release --verbose Fresh cc v1.0.28 Fresh autocfg v0.1.1 Fresh version_check v0.1.5

Do a synchronous http client fetch within an actix thread

对着背影说爱祢 提交于 2021-02-11 06:57:19
问题 I have an actix endpoint, and I need to do a synchronous http client fetch to get some results, and return some data. My endpoints cannot use async , so I can't use any .await methods. I've tried using reqwests blocking client in my endpoint like so: { ... let res = reqwest::blocking::get(&fetch_url)? .json::<MyResp>()?; ... But it gives me the error: thread 'main' panicked at 'Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block

Do a synchronous http client fetch within an actix thread

吃可爱长大的小学妹 提交于 2021-02-11 06:57:19
问题 I have an actix endpoint, and I need to do a synchronous http client fetch to get some results, and return some data. My endpoints cannot use async , so I can't use any .await methods. I've tried using reqwests blocking client in my endpoint like so: { ... let res = reqwest::blocking::get(&fetch_url)? .json::<MyResp>()?; ... But it gives me the error: thread 'main' panicked at 'Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block

Service Mesh对比:Istio与Linkerd

纵饮孤独 提交于 2021-02-11 05:39:28
根据CNCF的最新年度调查,很多组织对Service Mesh表现出很高的兴趣,并且有一部分已经在生产环境中使用它们。你可能不知道Linkerd是市场上第一个Service Mesh,但是Istio使Service Mesh更受欢迎。这两个项目都是最前沿的项目,而且竞争非常激烈,因此很难选择一个项目。 在本篇文章中,我们将和你一起了解Istio和Linkerd架构,组件,并比较它们的产品以帮助你做出明智的决定。 Service Mesh简介 在过去的几年中,微服务架构已成为软件设计中流行的样式。在这种架构中,我们将应用程序分解为可独立部署的服务。这些服务通常是轻量级的,多语言的,并且通常由各种职能团队进行开发部署。 当某些服务数量增加,难以管理且越来越复杂时,微服务架构将一直有效。但这也在管理安全性,网络流量控制和可观察性等各个方面带来了挑战。 Service Mesh可以很好地帮助应对这些挑战。 Service Mesh 用于描述组成应用程序的微服务及其之间的交互。随着服务数量的增加和复杂性的增加,扩展和管理变得越来越困难。Service Mesh可以为微服务架构提供服务发现,负载均衡,故障恢复,指标和监视。 Service Mesh 通常还能够满足更复杂的需求,例如A/B测试,金丝雀发布,速率限制,访问控制和端到端身份验证。 Service Mesh

Why do I not get a wakeup for multiple futures when they use the same underlying socket?

梦想与她 提交于 2021-02-11 04:54:57
问题 I have code which sends data to multiple UDP endpoints using same local UdpSocket: use futures::stream::FuturesUnordered; use futures::StreamExt; use std::{ future::Future, net::{Ipv4Addr, SocketAddr}, pin::Pin, task::{Context, Poll}, }; use tokio::net::UdpSocket; #[tokio::main] async fn main() { let server_0: SocketAddr = (Ipv4Addr::UNSPECIFIED, 12000).into(); let server_2: SocketAddr = (Ipv4Addr::UNSPECIFIED, 12002).into(); let server_1: SocketAddr = (Ipv4Addr::UNSPECIFIED, 12001).into();

How to reuse common codes for structs?

ぐ巨炮叔叔 提交于 2021-02-11 01:53:03
问题 I want to reuse codes for structs. For example: use std::fmt::Display; struct CommonStruct<T: Display> { // could have more fields data: T } struct A<T: Display> { com: CommonStruct<T>, age: i32 } struct B<T: Display> { com: CommonStruct<T>, name: String } impl<T: Display> A<T> { // could be more common functions fn print_data(&self) { // could be more complicated println!("data: {}", self.com.data); } } impl<T: Display> B<T> { // could be more common functions fn print_data(&self) { // could

error[E0106]: missing lifetime specifier (despite it being set) [duplicate]

早过忘川 提交于 2021-02-11 00:20:46
问题 This question already has answers here : Contradictory “missing lifetime specifier” error on owned value [duplicate] (1 answer) Getting 'Missing Lifetime specifier' error (1 answer) Why do I get “missing lifetime specifier” or “wrong number of type arguments” when implementing a trait for a struct? (1 answer) Closed 2 years ago . Consider the following code: extern crate clap; use clap::{App}; use std::io; fn parse_argv() -> &'static clap::ArgMatches { return App::new("example") .get_matches(

error[E0106]: missing lifetime specifier (despite it being set) [duplicate]

谁说我不能喝 提交于 2021-02-11 00:20:28
问题 This question already has answers here : Contradictory “missing lifetime specifier” error on owned value [duplicate] (1 answer) Getting 'Missing Lifetime specifier' error (1 answer) Why do I get “missing lifetime specifier” or “wrong number of type arguments” when implementing a trait for a struct? (1 answer) Closed 2 years ago . Consider the following code: extern crate clap; use clap::{App}; use std::io; fn parse_argv() -> &'static clap::ArgMatches { return App::new("example") .get_matches(

“blocking annotated I/O must be called from the context of the Tokio runtime” when reading stdin in async task

回眸只為那壹抹淺笑 提交于 2021-02-10 23:27:37
问题 I'm trying to read from stdin in an async task, spawned with tokio::spawn . The executor is crated as let mut executor = tokio::runtime::current_thread::Runtime::new().unwrap(); the main task is then run with executor.task(...) , which spawns other tasks with tokio::spawn() . fn main then calls executor.run().unwrap(); to wait for all tasks to finish. The problem is when I do let mut stdin = tokio::io::stdin(); let mut read_buf: [u8; 1024] = [0; 1024]; ... stdin.read(&mut read_buf).await I