Book - Actix user guides

Overview

User guides Build Status Join the chat at https://gitter.im/actix/actix

Using this library

This repository is an mdBook project. To use it for this project:

  • Install mdBook if you haven't already: cargo install mdbook
  • In the actix directory: mdbook watch -o
    • This automatically opens your browser and watches the md files for changing
    • You'll still have to refresh the page, as there is no hot-reloading for mdbook
Comments
  • Example does not build

    Example does not build

    The example listed in https://actix.rs/book/actix/sec-2-actor.html#complete-example does not build for me. I saw two problems:

    • I had to update the Cargo.toml file to include a dependency on the futures crate.

    • I see the following compiler error after adding the dependency on the futures crate:

      Compiling actor-ping v0.1.0 (/home/akhi/projects/actor-ping)
    warning: unused import: `futures::Future`
     --> src/main.rs:2:5
      |
    2 | use futures::Future;
      |     ^^^^^^^^^^^^^^^
      |
      = note: `#[warn(unused_imports)]` on by default
    
    error[E0599]: no method named `map` found for type `actix::address::message::Request<MyActor, Ping>` in the current scope
      --> src/main.rs:52:14
       |
    52 |             .map(|res| match res {
       |              ^^^ method not found in `actix::address::message::Request<MyActor, Ping>`
       |
       = note: the method `map` exists but the following trait bounds were not satisfied:
               `&mut actix::address::message::Request<MyActor, Ping> : futures::stream::Stream`
               `&mut actix::address::message::Request<MyActor, Ping> : std::iter::Iterator`
       = help: items from traits can only be used if the trait is in scope
    help: the following trait is implemented but not in scope; perhaps add a `use` for it:
       |
    1  | use futures::future::Future;
       |
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0599`.
    error: could not compile `actor-ping`.
    
    To learn more, run the command again with --verbose.
    

    The version I am using is:

    $ cargo --version
    cargo 1.41.0
    
    opened by akhi3030 4
  • Update to 0.9/0.10-alpha [Section 1]

    Update to 0.9/0.10-alpha [Section 1]

    This is the first PR towards closing #44. My goal is to update all the sections/pages of the book. After this PR is merged I'll submit different PRs for the rest of the pages.

    opened by savekirk 4
  • Example from the Arbiter chapter fails to compile

    Example from the Arbiter chapter fails to compile

    The example in arbiter chapter does not compile.

    I'm compiling on rust nightly rustc 1.43.0-nightly (8aa9d2014 2020-02-21)

    warning: unused import: `futures::Future`
     --> src/main.rs:4:5
      |
    4 | use futures::Future;
      |     ^^^^^^^^^^^^^^^
      |
      = note: `#[warn(unused_imports)]` on by default
    
    error[E0599]: no method named `map_err` found for struct `actix::prelude::Request<SumActor, Value>` in the current scope
      --> src/main.rs:63:10
       |
    63 |         .map_err(|e| {
       |          ^^^^^^^ method not found in `actix::prelude::Request<SumActor, Value>`
       |
       = help: items from traits can only be used if the trait is in scope
    help: the following trait is implemented but not in scope; perhaps add a `use` for it:
       |
    3  | use crate::futures::TryFutureExt;
       |
    
    error[E0599]: no method named `map` found for struct `actix::prelude::Request<DisplayActor, Display>` in the current scope
      --> src/main.rs:74:41
       |
    74 |             dis_addr.send(Display(res)).map(move |_| ()).map_err(|_| ())
       |                                         ^^^ method not found in `actix::prelude::Request<DisplayActor, Display>`
       |
       = note: the method `map` exists but the following trait bounds were not satisfied:
               `&mut actix::prelude::Request<DisplayActor, Display> : std::iter::Iterator`
       = help: items from traits can only be used if the trait is in scope
    help: the following trait is implemented but not in scope; perhaps add a `use` for it:
       |
    3  | use crate::futures::FutureExt;
       |
    
    error: aborting due to 2 previous errors
    
    For more information about this error, try `rustc --explain E0599`.
    error: could not compile `actix-middleware-tryout`.
    
    To learn more, run the command again with --verbose.
    

    Tried adding suggested use statements, but no luck.

    warning: unused import: `futures::Future`
     --> src/main.rs:4:5
      |
    4 | use futures::Future;
      |     ^^^^^^^^^^^^^^^
      |
      = note: `#[warn(unused_imports)]` on by default
    
    error[E0599]: no method named `map_err` found for struct `futures::future::Map<actix::prelude::Request<DisplayActor, Display>, [closure@src/main.rs:76:45: 76:56]>` in the current scope
      --> src/main.rs:76:58
       |
    76 |             dis_addr.send(Display(res)).map(move |_| ()).map_err(|_| ())
       |                                                          ^^^^^^^ method not found in `futures::future::Map<actix::prelude::Request<DisplayActor, Display>, [closure@src/main.rs:76:45: 76:56]>`
       |
       = note: the method `map_err` exists but the following trait bounds were not satisfied:
               `&futures::future::Map<actix::prelude::Request<DisplayActor, Display>, [closure@src/main.rs:76:45: 76:56]> : futures::TryFutureExt`
               `&mut futures::future::Map<actix::prelude::Request<DisplayActor, Display>, [closure@src/main.rs:76:45: 76:56]> : futures::TryFutureExt`
               `futures::future::Map<actix::prelude::Request<DisplayActor, Display>, [closure@src/main.rs:76:45: 76:56]> : futures::TryFutureExt`
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0599`.
    error: could not compile `actix-middleware-tryout`.
    
    To learn more, run the command again with --verbose.
    
    opened by f8122dac 4
  • Updated sec-1 to match ping example code

    Updated sec-1 to match ping example code

    I noticed the Getting Started section still uses Actix 0.8 and Futures but the ping example has moved on to use the newer async await standard without Futures.

    I did run cargo test before committing and there's one outstanding failed test for sec-1:

    test sec_1_getting_started_sect_ping_actor_line_115 ... FAILED
    warning: struct is never constructed: `Ping`
     --> /tmp/rust-skeptic.Is0iZA6jfrsE/test.rs:5:1
      |
    5 | struct Ping(usize);
      | ^^^^^^^^^^^^^^^^^^^
      |
      = note: `#[warn(dead_code)]` on by default
    

    I'm not entirely sure, but I think this test failed due to skeptic.rs not being able to grok the new await syntax so it thinks the Ping struct wasn't used.

    This is my first Rust-related PR so let me know if there's anything I missed! I would greatly appreciated the guidance!

    opened by raymondsiu 4
  • Improve arbiter documentation

    Improve arbiter documentation

    Right now this is kind of redundant on #24 for the README. Once that's pulled, the PR will look cleaner and only one file will have changed.

    Mostly this PR encompasses 2 major changes to the Arbiter page:

    • Describes the event loop that Actix/arbiters use
      • I speak maybe too specifically to people who are familiar with JS because that's me and this is the way it made clearest sense to me.
      • I could be totally wrong. Part of this PR is a question: Is this the way it works?
    • Make example much cleaner and more user friendly with more comments and explanation.
      • I spend perhaps too much time explaining the Futures aspect, but I think a lot of people who are new to Actix are also at least somewhat new to Futures. This is Rust: everyone's new to everything. So I erred on the side of over-explaining.
    opened by rivertam 4
  • Improve context documentation.

    Improve context documentation.

    This improves the context chapter of the actix box, to have a function mailbox capacity example, and adds examples for stop and address in the context.

    Author: William Brown [email protected]

    opened by Firstyear 3
  • Expand on the errors guide for actix-web

    Expand on the errors guide for actix-web

    As discussed in a previous actix-web thread on errors [1], it might be nice to add a little more flavor to the user guide on error handling, with some focus on recommended practices.

    This patch makes a few changes:

    1. Adds a "Recommended practices in error handling" section with a few more ideas on how errors might be effectively used in a real application.
    2. Adds a "Compatibility with failure" section.
    3. Rewrites most of the other sections for clarity/succinctness.

    [1] https://github.com/actix/actix-web/issues/197

    cc @fafhrd91

    opened by brandur 3
  • Re-enable tests

    Re-enable tests

    So these tests were disabled about a year back in 2db214f and it actually resulted in the book getting broken unnoticed (see #33). I suggest re-enabling these tests. They were apparently broken due to travis failures.

    opened by svenstaro 2
  • WIP - 2019 03 24 streams documentation

    WIP - 2019 03 24 streams documentation

    This is documentation of streams in actix, using an echo server to demonstrate their usage.

    This is a WIP with the intent of @rivertam to review pending other reviews.

    Today there are three review points

    • How to make urls proper links?
    • What are the cause of the compilation errors in cargo test of the book?
    • Wording and docs review

    TODO:

    • Add TLS echo example
    opened by Firstyear 2
  • Addresses typo

    Addresses typo

    Here it shows to exactly the same code snippets saying

    Same example, but returned address is thread safe and can be sent to different thread.

    which is probably wrong.

    opened by TatriX 2
  • Initial rev of Coming From Akka

    Initial rev of Coming From Akka

    This is pretty rough and incomplete, but better than nothing. Let me know if anything is incorrect or needs to change. I did my best to cross reference the latest code to make sure it's truthful.

    opened by tkellogg 2
  • [WIP] Migrate to newest Actix

    [WIP] Migrate to newest Actix

    ATTENTION maintainers: several of the examples need your expert opinion - they are currently panicking with

    thread 'main' panicked at '`spawn_local` called from outside of a `task::LocalSet`', .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/task/local.rs:306:18
    
    • Update to latest Actix
    • Fix build instructions
    • Mark several tests as failing to avoid confusing users
    opened by nyurik 3
  • Would love to see the supervisor and registry in the user guide.

    Would love to see the supervisor and registry in the user guide.

    Hello!

    We love actix actor framework and we've been using it in our production development for an year now. We've been using the registry functionality in our code, and mostly been reading the API documentation and the code to figure out how to use the features, but it would be really nice if these features were explained by the developers in the user guide.

    help wanted 
    opened by f8122dac91 1
Owner
Actix
Actix - web and actor frameworks for Rust
Actix
This repository contains the source of "The Rust Programming Language" book.

The Rust Programming Language This repository contains the source of "The Rust Programming Language" book. The book is available in dead-tree form fro

The Rust Programming Language 11.2k Jan 8, 2023
A library for extracting #[no_mangle] pub extern "C" functions (https://docs.rust-embedded.org/book/interoperability/rust-with-c.html#no_mangle)

A library for extracting #[no_mangle] pub extern "C" functions In order to expose a function with C binary interface for interoperability with other p

Dmitrii - Demenev 0 Feb 17, 2022
clone of grep cli written in Rust. From Chapter 12 of the Rust Programming Language book

minigrep is a clone of the grep cli in rust Minigrep will find a query string in a file. To test it out, clone the project and run cargo run body poem

Raunak Singh 1 Dec 14, 2021
The ray tracer challenge in rust - Repository to follow my development of "The Raytracer Challenge" book by Jamis Buck in the language Rust

The Ray Tracer Challenge This repository contains all the code written, while step by implementing Ray Tracer, based on the book "The Ray Tracer Chall

Jakob Westhoff 54 Dec 25, 2022
Complete code for the larger example programs from the book.

Code Examples for Programming Rust This repository contains complete code for the larger example programs from the book “Programming Rust”, by Jim Bla

Programming Rust 670 Jan 1, 2023
Source code for the book Rust in Action

Welcome to Rust in Action source code This source code repository is a companion to the Rust in Action book available from Manning Publications. Suppo

Rust in Action 1.3k Dec 30, 2022
Code to follow along the "Zero To Production" book on API development in Rust.

Zero To Production / Code (Chapter 10 - Part 1) Zero To Production In Rust is an opinionated introduction to backend development using Rust. This repo

Luca Palmieri 2.8k Dec 31, 2022
Rust crate to implement a counterpart to the PBRT book's (3rd edition) C++ code.

Rust crate to implement a counterpart to the PBRT book's (3rd edition) C++ code.

Jan Walter 763 Dec 27, 2022
High Assurance Rust - A free book about developing secure and robust systems software.

High Assurance Rust - A free book about developing secure and robust systems software.

Tiemoko Ballo 1.1k Jan 9, 2023
Learn programming with Rust as a first language (book)

Learn programming with Rust as first language This is a book to learn programming from scratch. Read the book here: https://deavid.github.io/lprfl/ LI

David Martínez Martí 2 May 21, 2022
Majestic Lisp book and implementation, in Brazillian Portuguese.

Majestic Lisp Criado e desenvolvido por Lucas S. Vieira <lucasvieira at protonmail dot com>. Seja bem-vindo(a) a Majestic Lisp, um dialeto de Lisp cuj

Lucas Vieira 3 Oct 26, 2022
Search and read 'The Rust Book' from the terminal

TheBook TheBook is a command line utility that allows you to SEARCH and READ The Rust Programming Language (popularly known as 'The Book' ) from the t

0xHiro 技術者 239 Jan 4, 2023
Generate SUMMARY.md files based on your book's file structure

mdbook-autosummary Generate a SUMMARY.md for your mdBook based on your folder structure! Warning The implementation is hacky and has several limitatio

Hyper 3 Sep 30, 2023
A minimal version of 'grep' implemented in Rust. Exercise in the "The Rust Programming Language" book.

Minigrep - A simple grep-like tool implemented in Rust This simple CLI tool searches for a given pattern in a specified file and as a result, it print

Filip Szutkowski 3 Mar 15, 2024
Simple RESTful API in rust created with actix-web. (Routing, models, JWT auth).

rust-simple-api Simple RESTful API created with rust, actix-web, Diesel, JWT. Running application Manual Firstly generate a secret.key which will be u

null 2 Jul 30, 2022
Featured Dioxus projects on how to build clean user interfaces in Rust

Example projects with Dioxus This repository holds the code for a variety of example projects built with Dioxus. Each project has information on how t

Dioxus 189 Jan 8, 2023
Checks Crusader Kings 3 user mod files for common mistakes and warns about them.

ck3-tiger Pounces on bugs. Checks Crusader Kings 3 user mod files for common mistakes and warns about them. For example: missing localizations, or usi

Richard Braakman 8 Jan 5, 2023
A developer-friendly framework for building user interfaces in Rust

Reading: "Fru" as in "fruit" and "i" as in "I" (I am). What is Frui? Frui is a developer-friendly UI framework that makes building user interfaces eas

Frui Framework 1.1k Jan 8, 2023
A typesafe, flexible, simple, and user-friendly unit system library for Rust that has good error messages.

uy A typesafe, flexible, simple, and user-friendly unit system library for Rust that has good error messages. Usage uy not only stores the unit of a v

Lachlan Sneff 19 Aug 8, 2023