diff --git a/po/fa.po b/po/fa.po index a8a72c9c..785d8976 100644 --- a/po/fa.po +++ b/po/fa.po @@ -19212,46 +19212,60 @@ msgid "async/await" msgstr "async/await" #: src/concurrency/async/async-await.md:3 +#, fuzzy msgid "" "At a high level, async Rust code looks very much like \"normal\" sequential " "code:" msgstr "" +"در سطح بالا، کد Rust async بسیار شبیه کد متوالی \"عادی\" است (\"normal\" " +"sequential code):" #: src/concurrency/async/async-await.md:10 +#, fuzzy msgid "\"Count is: {i}!\"" -msgstr "" +msgstr "\"Count is: {i}!\"" #: src/concurrency/async/async-await.md:28 msgid "" "Note that this is a simplified example to show the syntax. There is no long " "running operation or any real concurrency in it!" msgstr "" +"توجه داشته باشید که این یک مثال ساده برای نشان دادن syntax است. هیچ عملیات " +"طولانی مدت یا هیچ هم‌زمانی(concurrency) واقعی در آن وجود ندارد!" #: src/concurrency/async/async-await.md:31 msgid "What is the return type of an async call?" -msgstr "" +msgstr "نوع برگشت async call چیست؟" #: src/concurrency/async/async-await.md:32 msgid "Use `let future: () = async_main(10);` in `main` to see the type." msgstr "" +"برای مشاهده type از `let future: () = async_main(10);` در `main` استفاده " +"کنید." #: src/concurrency/async/async-await.md:34 msgid "" "The \"async\" keyword is syntactic sugar. The compiler replaces the return " "type with a future." msgstr "" +"کلمه کلیدی \"async\" شیرینیِ syntax زبان Rust است. کامپایلر نوع بازگشتی را با " +"یک future جایگزین می‌کند." #: src/concurrency/async/async-await.md:37 msgid "" "You cannot make `main` async, without additional instructions to the " "compiler on how to use the returned future." msgstr "" +"شما نمی‌توانید بدون دستورالعمل‌های اضافی به کامپایلر در مورد نحوه استفاده از " +"future بازگشتی، `main` را async کنید." #: src/concurrency/async/async-await.md:40 msgid "" "You need an executor to run async code. `block_on` blocks the current thread " "until the provided future has run to completion." msgstr "" +"برای اجرای کدهای همگام به یک اجرا‌ کننده (executor) نیاز دارید.`block_on` که " +"thread رشته فعلی را تا زمانی که future ارائه شده تکمیل شود مسدود می‌کند." #: src/concurrency/async/async-await.md:43 msgid "" @@ -19264,6 +19278,8 @@ msgid "" "`.await` can only be used inside an `async` function (or block; these are " "introduced later)." msgstr "" +"‏ `.await` فقط می‌تواند در داخل یک تابع `async` استفاده شود (یا block؛ این " +"مورد در آینده معرفی می‌شوند)." #: src/concurrency/async/futures.md:3 msgid "" @@ -19272,6 +19288,10 @@ msgid "" "complete yet. A future can be polled, and `poll` returns a [`Poll`](https://" "doc.rust-lang.org/std/task/enum.Poll.html)." msgstr "" +" ‏[`Future`](https://doc.rust-lang.org/std/future/trait.Future.html) یک trait " +"است، اجرا شده توسط objectهایی که نشان دهنده عملیاتی هستند که ممکن است هنوز " +"کامل نشده باشد. می‌توان یک future را poll کرد و `poll` یک [`Poll`](https://" +"doc.rust-lang.org/std/task/enum.Poll.html) را برمی‌گرداند." #: src/concurrency/async/futures.md:23 msgid "" @@ -19280,30 +19300,42 @@ msgid "" "`JoinHandle` returned from `tokio::spawn` implements `Future` to allow " "joining to it." msgstr "" +"یک تابع async یک `impl Future` را برمی‌گرداند. همچنین امکان (اما غیرمعمول) " +"پیاده‌سازی `Future` برای تایپ‌های خودتان نیز وجود دارد. برای مثال، " +"`JoinHandle` برگردانده شده از `tokio::spawn` `Future` را پیاده‌سازی می‌کند تا " +"امکان پیوستن (joining) به آن را فراهم کند." #: src/concurrency/async/futures.md:27 msgid "" "The `.await` keyword, applied to a Future, causes the current async function " "to pause until that Future is ready, and then evaluates to its output." msgstr "" +"کلمه کلیدی `.await` که برای Future اعمال می‌شود، باعث می‌شود که تابع async " +"فعلی تا زمانی که Future آماده شود متوقف شود و سپس خروجی آن ارزیابی شود." #: src/concurrency/async/futures.md:33 msgid "" "The `Future` and `Poll` types are implemented exactly as shown; click the " "links to show the implementations in the docs." msgstr "" +"تایپ‌های `Future` و `Poll` دقیقاً همانطور که نشان داده شده است اجرا می شوند. " +"برای نمایش پیاده‌سازی‌ها در اسناد، روی لینک‌ها کلیک کنید." #: src/concurrency/async/futures.md:36 msgid "" "We will not get to `Pin` and `Context`, as we will focus on writing async " "code, rather than building new async primitives. Briefly:" msgstr "" +"ما به `Pin` و `Context` نخواهیم رسید، زیرا به جای ساختن کدهای اولیه async، " +"بر نوشتن کدهای async تمرکز خواهیم کرد. به طور خلاصه:" #: src/concurrency/async/futures.md:39 msgid "" "`Context` allows a Future to schedule itself to be polled again when an " "event occurs." msgstr "" +"‏ `Context` به Future اجازه می‌دهد تا زمانی که رویدادی رخ می دهد، خود را برای " +"poll مجدد برنامه‌ریزی کند." #: src/concurrency/async/futures.md:42 msgid "" @@ -19311,6 +19343,9 @@ msgid "" "that future remain valid. This is required to allow references to remain " "valid after an `.await`." msgstr "" +"‏ `Pin` تضمین می‌کند که Future در حافظه جابه‌جا نمی‌شود، بنابراین pointerهای " +"future معتبر باقی می‌مانند. این برای اجازه دادن به referenceها برای معتبر " +"ماندن پس از `.await` لازم است." #: src/concurrency/async/runtimes.md:3 msgid "" @@ -19318,6 +19353,9 @@ msgid "" "_reactor_) and is responsible for executing futures (an _executor_). Rust " "does not have a \"built-in\" runtime, but several options are available:" msgstr "" +"یک _runtime_ برای انجام عملیات به صورت ناهمزمان از (a_reactor_) پشتیبانی می " +"کند و مسئول اجرای futureها (an _executor_) است. Rust یک runtime داخلی ندارد، " +"اما چندین گزینه دیگر در دسترس است:" #: src/concurrency/async/runtimes.md:7 msgid "" @@ -19325,16 +19363,21 @@ msgid "" "functionality like [Hyper](https://hyper.rs/) for HTTP or [Tonic](https://" "github.com/hyperium/tonic) for gRPC." msgstr "" +"‏[Tokio](https://tokio.rs/): کارایی(performant)، با یک اکوسیستم با کارایی " +"بالا به خوبی توسعه یافته مانند [Hyper](https://hyper.rs/) برای HTTP یا " +"[Tonic] (https://github) .com/hyperium/tonic) برای gRPC." #: src/concurrency/async/runtimes.md:10 msgid "" "[async-std](https://async.rs/): aims to be a \"std for async\", and includes " "a basic runtime in `async::task`." msgstr "" +"‏[async-std](https://async.rs/):: هدفش این است که یک \"std for async\" باشد و " +"شامل یک runtime اولیه در `async::task` است." #: src/concurrency/async/runtimes.md:12 msgid "[smol](https://docs.rs/smol/latest/smol/): simple and lightweight" -msgstr "" +msgstr "‏[smol](https://docs.rs/smol/latest/smol/): ساده و سبک است." #: src/concurrency/async/runtimes.md:14 msgid "" @@ -19342,6 +19385,9 @@ msgid "" "(https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/src/lib/fuchsia-" "async/src/lib.rs) already has one." msgstr "" +"چندین برنامه بزرگتر زمان اجرا (runtime) مخصوص به خود را دارند. برای مثال، " +"[Fuchsia](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/src/lib/" +"fuchsia-async/src/lib.rs) اکنون یکی runtime دارد." #: src/concurrency/async/runtimes.md:21 msgid "" @@ -19349,6 +19395,9 @@ msgid "" "playground. The playground also does not permit any I/O, so most interesting " "async things can't run in the playground." msgstr "" +"توجه داشته باشید که از میان زمان‌های اجرا ذکر شده، فقط Tokio در playground " +"زبان Rust پشتیبانی می‌شود.playground همچنین اجازه ورود/خروجی (I/O) را نمی " +"دهد، بنابراین بیشتر چیزهای async جالب نمی‌توانند در playground اجرا شوند." #: src/concurrency/async/runtimes.md:25 msgid "" @@ -19357,46 +19406,55 @@ msgid "" "Promises, for example, which will run to completion even if they are never " "used." msgstr "" +"‏ Futureها از این جهت «بی‌اثر(inert)» هستند که هیچ کاری انجام نمی‌دهند (حتی " +"عملیات I/O را شروع نمی‌کنند) مگر اینکه یک مجری(executor) وجود داشته باشد که " +"آنها را polling کند. به عنوان مثال، این با JS Promises متفاوت است که حتی اگر " +"هرگز استفاده نشوند تا پایان کامل شدن برنامه اجرا خواهند شد." #: src/concurrency/async/runtimes/tokio.md:3 +#, fuzzy msgid "Tokio provides:" -msgstr "" +msgstr "Tokio provides:" #: src/concurrency/async/runtimes/tokio.md:5 msgid "A multi-threaded runtime for executing asynchronous code." msgstr "" +"یک runtime از نوع multi-thread برای اجرای کدهای ناهمزمان(asynchronous)." #: src/concurrency/async/runtimes/tokio.md:6 msgid "An asynchronous version of the standard library." -msgstr "" +msgstr "یک asynchronous version کتابخانه‌ای استاندارد است." #: src/concurrency/async/runtimes/tokio.md:7 msgid "A large ecosystem of libraries." -msgstr "" +msgstr "اکوسیستم بزرگی از کتابخانه‌ها." #: src/concurrency/async/runtimes/tokio.md:14 +#, fuzzy msgid "\"Count in task: {i}!\"" -msgstr "" +msgstr "\"connection from {addr:?}\"" #: src/concurrency/async/runtimes/tokio.md:24 +#, fuzzy msgid "\"Main task: {i}\"" -msgstr "" +msgstr "\"Main task: {i}\"" #: src/concurrency/async/runtimes/tokio.md:32 msgid "With the `tokio::main` macro we can now make `main` async." -msgstr "" +msgstr "با ماکرو `tokio::main` اکنون می‌توانیم `main` را async کنیم." #: src/concurrency/async/runtimes/tokio.md:34 msgid "The `spawn` function creates a new, concurrent \"task\"." -msgstr "" +msgstr "تابع `spawn` یک \"task\" جدید و همزمان ایجاد می‌کند." #: src/concurrency/async/runtimes/tokio.md:36 msgid "Note: `spawn` takes a `Future`, you don't call `.await` on `count_to`." msgstr "" +"توجه: `spawn` یک `Future` می‌گیرد، شما `.await` را در `count_to` صدا نمی‌زنید." #: src/concurrency/async/runtimes/tokio.md:38 msgid "**Further exploration:**" -msgstr "" +msgstr "**Further بررسی:**" #: src/concurrency/async/runtimes/tokio.md:40 msgid "" @@ -19404,18 +19462,20 @@ msgid "" "cancellation. `tokio::spawn` returns a handle which can be awaited to wait " "until it finishes." msgstr "" +"چرا `count_to` (معمولا) به مقدار ۱۰ نمی‌رسد؟ این نمونه‌ای از لغو async است. " +"`tokio::spawn` یک handle را برمی‌گرداند که می‌توان مدتی منتظر ماند تا تمام شود." #: src/concurrency/async/runtimes/tokio.md:44 msgid "Try `count_to(10).await` instead of spawning." -msgstr "" +msgstr "به جای spawn مورد `count_to(10).await`» را امتحان کنید." #: src/concurrency/async/runtimes/tokio.md:46 msgid "Try awaiting the task returned from `tokio::spawn`." -msgstr "" +msgstr "منتظر کار برگشتی از `tokio::spawn` باشید." #: src/concurrency/async/tasks.md:3 msgid "Rust has a task system, which is a form of lightweight threading." -msgstr "" +msgstr "‏ Rust یک task system دارد که نوعی thread سبک‌ وزن است." #: src/concurrency/async/tasks.md:5 msgid "" @@ -19425,37 +19485,49 @@ msgid "" "task is possible by polling multiple child futures, such as racing a timer " "and an I/O operation." msgstr "" +"یک task یک future در سطح بالا دارد که اجراکننده (executor) برای ادامه کار آن " +"را poll می‌کند. آن future ممکن است یک یا چند future تودرتو داشته باشد که متد " +"`poll` آن را `poll` می‌کند، که به طور ناپایداری با یک stack فراخوانی شده " +"مطابقت دارد. همزمانی در یک task با poll از چندین child future، مانند رقابت " +"یک تایمر و یک عملیات I/O امکان‌پذیر است." #: src/concurrency/async/tasks.md:16 msgid "\"127.0.0.1:0\"" -msgstr "" +msgstr "\"127.0.0.1:0\"" #: src/concurrency/async/tasks.md:17 +#, fuzzy msgid "\"listening on port {}\"" -msgstr "" +msgstr "\"listening on port {}\"" #: src/concurrency/async/tasks.md:22 +#, fuzzy msgid "\"connection from {addr:?}\"" -msgstr "" +msgstr "\"connection from {addr:?}\"" #: src/concurrency/async/tasks.md:25 +#, fuzzy msgid "b\"Who are you?\\n\"" -msgstr "" +msgstr "b\"Who are you?\\n\"" #: src/concurrency/async/tasks.md:25 src/concurrency/async/tasks.md:28 #: src/concurrency/async/tasks.md:31 +#, fuzzy msgid "\"socket error\"" -msgstr "" +msgstr "\"socket error\"" #: src/concurrency/async/tasks.md:30 +#, fuzzy msgid "\"Thanks for dialing in, {name}!\\n\"" -msgstr "" +msgstr "\"Thanks for dialing in, {name}!\\n\"" #: src/concurrency/async/tasks.md:40 #: src/concurrency/async-control-flow/join.md:37 msgid "" "Copy this example into your prepared `src/main.rs` and run it from there." msgstr "" +"این مثال را در `src/main.rs` آماده شده خود کپی کنید و آن را از آنجا اجرا " +"کنید." #: src/concurrency/async/tasks.md:42 msgid "" @@ -19463,64 +19535,83 @@ msgid "" "com/man-page/linux/1/nc/) or [telnet](https://www.unix.com/man-page/linux/1/" "telnet/)." msgstr "" +"سعی کنید با یک ابزار اتصال TCP مانند [nc](https://www.unix.com/man-page/" +"linux/1/nc/) یا [telnet](https://www.unix.com/) به آن متصل شوید." #: src/concurrency/async/tasks.md:46 +#, fuzzy msgid "" "Ask students to visualize what the state of the example server would be with " "a few connected clients. What tasks exist? What are their Futures?" msgstr "" +"از دانش‌آموزان بخواهید که وضعیت سرور مورد مثال را با چند کلاینت متصل تجسم " +"کنند. چه taskهایی وجود دارد؟ Future آنها چیست؟" #: src/concurrency/async/tasks.md:49 +#, fuzzy msgid "" "This is the first time we've seen an `async` block. This is similar to a " "closure, but does not take any arguments. Its return value is a Future, " "similar to an `async fn`." msgstr "" +"این اولین بار است که بلوک `async` را می‌بینیم. این شبیه به بسته شدن است، اما " +"هیچ استدلالی ندارد. مقدار بازگشتی آن از نوع Future است، شبیه به `async fn`." #: src/concurrency/async/tasks.md:53 msgid "" "Refactor the async block into a function, and improve the error handling " "using `?`." msgstr "" +"بلوک async را به یک تابع تغییر دهید و مدیریت خطا را با استفاده از `?` بهبود " +"بخشید." #: src/concurrency/async-control-flow/channels.md:3 msgid "" "Several crates have support for asynchronous channels. For instance `tokio`:" msgstr "" +"چندین crate از asynchronous channel پشتیبانی می‌کنند. به عنوان مثال `tokio`:" #: src/concurrency/async-control-flow/channels.md:13 +#, fuzzy msgid "\"Received {count} pings so far.\"" -msgstr "" +msgstr "\"Received {count} pings so far.\"" #: src/concurrency/async-control-flow/channels.md:16 +#, fuzzy msgid "\"ping_handler complete\"" -msgstr "" +msgstr "\"ping_handler complete\"" #: src/concurrency/async-control-flow/channels.md:24 +#, fuzzy msgid "\"Failed to send ping.\"" -msgstr "" +msgstr "\"Failed to send ping.\"" #: src/concurrency/async-control-flow/channels.md:25 +#, fuzzy msgid "\"Sent {} pings so far.\"" -msgstr "" +msgstr "\"Sent {} pings so far.\"" #: src/concurrency/async-control-flow/channels.md:29 +#, fuzzy msgid "\"Something went wrong in ping handler task.\"" -msgstr "" +msgstr "\"Something went wrong in ping handler task.\"" #: src/concurrency/async-control-flow/channels.md:36 msgid "Change the channel size to `3` and see how it affects the execution." msgstr "" +"اندازه کانال را به`3` تغییر دهید و ببینید که چگونه بر اجرا تأثیر می‌گذارد." #: src/concurrency/async-control-flow/channels.md:38 msgid "" "Overall, the interface is similar to the `sync` channels as seen in the " "[morning class](../channels.md)." msgstr "" +"به‌طور‌کلی، interface شبیه به channelهای `sync` است که در [کلاس صبح‌گاهی](../" +"channels.md) دیده می‌شود." #: src/concurrency/async-control-flow/channels.md:41 msgid "Try removing the `std::mem::drop` call. What happens? Why?" -msgstr "" +msgstr "تماس `std::mem::drop` را حذف کنید. چه اتفاقی می‌افتد؟ چرا؟" #: src/concurrency/async-control-flow/channels.md:43 msgid "" @@ -19528,6 +19619,9 @@ msgid "" "implement both `sync` and `async` `send` and `recv`. This can be convenient " "for complex applications with both IO and heavy CPU processing tasks." msgstr "" +"این crate مربوط به [Flume](https://docs.rs/flume/latest/flume/) دارای " +"کانال‌هایی است که `sync` و `async` `send` و `recv` را اجرا می‌کنند. این کار " +"می‌تواند برای برنامه‌های پیچیده با taskهای پردازشی IO و CPU سنگین مناسب باشد." #: src/concurrency/async-control-flow/channels.md:47 msgid "" @@ -19535,6 +19629,8 @@ msgid "" "combine them with other `future`s to combine them and create complex control " "flow." msgstr "" +"چیزی که کار با کانال‌های `async` را ترجیح می‌دهد، توانایی ترکیب آن‌ها با دیگر " +"`future` برای ترکیب آنها و ایجاد جریان کنترل پیچیده است." #: src/concurrency/async-control-flow/join.md:3 msgid "" @@ -19542,22 +19638,28 @@ msgid "" "a collection of their results. This is similar to `Promise.all` in " "JavaScript or `asyncio.gather` in Python." msgstr "" +"عملیات پیوستن (join) منتظر می‌ماند تا تمام مجموعه‌ای از futureها آماده شوند و " +"مجموعه‌ای (collection) از نتایج آنها را برمی‌گرداند. این شبیه به `Promise.all` " +"در JavaScript یا `asyncio.gather` در پایتون است." #: src/concurrency/async-control-flow/join.md:21 +#, fuzzy msgid "\"https://google.com\"" -msgstr "" +msgstr "\"https://google.com\"" #: src/concurrency/async-control-flow/join.md:22 +#, fuzzy msgid "\"https://httpbin.org/ip\"" -msgstr "" +msgstr "\"https://httpbin.org/ip\"" #: src/concurrency/async-control-flow/join.md:23 +#, fuzzy msgid "\"https://play.rust-lang.org/\"" -msgstr "" +msgstr "\"https://play.rust-lang.org/\"" #: src/concurrency/async-control-flow/join.md:24 msgid "\"BAD_URL\"" -msgstr "" +msgstr "\"BAD_URL\"" #: src/concurrency/async-control-flow/join.md:39 msgid "" @@ -19565,12 +19667,18 @@ msgid "" "you must know how many futures you will have at compile time. This is " "currently in the `futures` crate, soon to be stabilised in `std::future`." msgstr "" +"برای چند future از تایپ‌های مختلف، می‌توانید از `std::future::join!` استفاده " +"کنید، اما باید بدانید که در زمان کامپایل چند future خواهید داشت. این در حال " +"حاضر در جعبه (crate از نوع `futures` است که به زودی در `std::future` تثبیت " +"می‌شود." #: src/concurrency/async-control-flow/join.md:43 msgid "" "The risk of `join` is that one of the futures may never resolve, this would " "cause your program to stall." msgstr "" +"خطر `join` این است که یکی از future‌ها ممکن است هرگز resolve نشود، این مسئله " +"باعث می‌شود برنامه شما متوقف شود." #: src/concurrency/async-control-flow/join.md:46 msgid "" @@ -19580,6 +19688,11 @@ msgid "" "timeout (that requires `select!`, explained in the next chapter), but " "demonstrates `join!`." msgstr "" +"همچنین می‌توانید `join_all` را با `join!` ترکیب کنید، به‌عنوان مثال برای " +"پیوستن (`join!`) همه درخواست‌ها به یک سرویس http و همچنین یک کوئری پایگاه " +"داده سعی کنید `tokio::time::sleep` را با استفاده از `futures::join!` به " +"future اضافه کنید. این یک timeout نیست (که به `select!`نیاز دارد و در فصل " +"بعدی توضیح داده ‌می‌شود) بلکه `join!` را نشان می‌دهد." #: src/concurrency/async-control-flow/select.md:3 msgid "" @@ -19588,6 +19701,10 @@ msgid "" "race`. In Python, it compares to `asyncio.wait(task_set, return_when=asyncio." "FIRST_COMPLETED)`." msgstr "" +"یک عملیات انتخابی منتظر می‌ماند تا هر یک از مجموعه‌ای از futureها آماده شود و " +"به نتیجه آن future پاسخ می‌دهد. در JavaScript این مورد شبیه به `Promise.race` " +"است و در پایتون با `asyncio.wait(task_set, return_when=asyncio." +"FIRST_COMPLETED)` قابل مقایسه می‌باشد." #: src/concurrency/async-control-flow/select.md:8 msgid "" @@ -19597,26 +19714,36 @@ msgid "" "run with the resulting variables. The `statement` result becomes the result " "of the `select!` macro." msgstr "" +"مانند یک عبارت تطبیقی (match statement)، بدنه `pattern` دارای تعدادی بازو " +"است که هر کدام به شکل عبارت `pattern = future => statement` هستند. هنگامی که " +"`future` آماده است، مقدار بازگشتی آن توسط `pattern` تخریب می‌شود. سپس " +"`statement` با متغیرهای حاصل اجرا می‌شود. در نتیجه `statement` نتیجه‌ي ماکرو " +"`select!` می‌شود." #: src/concurrency/async-control-flow/select.md:40 +#, fuzzy msgid "\"Felix\"" -msgstr "" +msgstr "\"Felix\"" #: src/concurrency/async-control-flow/select.md:40 +#, fuzzy msgid "\"Failed to send cat.\"" -msgstr "" +msgstr "\"Failed to send cat.\"" #: src/concurrency/async-control-flow/select.md:44 +#, fuzzy msgid "\"Failed to send dog.\"" -msgstr "" +msgstr "\"Failed to send dog.\"" #: src/concurrency/async-control-flow/select.md:49 +#, fuzzy msgid "\"Failed to receive winner\"" -msgstr "" +msgstr "\"Failed to receive winner\"" #: src/concurrency/async-control-flow/select.md:51 +#, fuzzy msgid "\"Winner is {winner:?}\"" -msgstr "" +msgstr "\"Winner is {winner:?}\"" #: src/concurrency/async-control-flow/select.md:58 msgid "" @@ -19625,30 +19752,44 @@ msgid "" "whichever arrives first. Since the dog takes 50ms, it wins against the cat " "that take 500ms." msgstr "" +"در این مثال مسابقه‌ای بین گربه و سگ داریم. `first_animal_to_finish_race` به " +"هر دو channelها گوش می‌دهد و هر کدام را زودتر وارد شوند را انتخاب می‌کند." +"بنابراین سگ ۵۰ میلی‌ثانیه طول می‌کشد، در برابر گربه‌ای که ۵۰۰ میلی‌ثانیه طول " +"می‌کشد تا پیروز شود." #: src/concurrency/async-control-flow/select.md:63 msgid "" "You can use `oneshot` channels in this example as the channels are supposed " "to receive only one `send`." msgstr "" +"در این مثال می‌توانید از کانال‌های `oneshot` استفاده کنید زیرا قرار است " +"کانال‌ها فقط یک `send` را دریافت کنند." #: src/concurrency/async-control-flow/select.md:66 msgid "" "Try adding a deadline to the race, demonstrating selecting different sorts " "of futures." msgstr "" +"سعی کنید یک ضرب الاجل به رقابت اضافه کنید و انتخاب انواع مختلف future را " +"نشان دهید." #: src/concurrency/async-control-flow/select.md:69 msgid "" "Note that `select!` drops unmatched branches, which cancels their futures. " "It is easiest to use when every execution of `select!` creates new futures." msgstr "" +"توجه داشته باشید که `select!` شاخه‌های (branch) بی‌همتا را حذف می کند و " +"future آنها را لغو می‌کند. زمانی که هر اجرای `select!` می‌تواند future‌های " +"جدیدی ایجاد می‌کند، راحت‌ترین استفاده از آن است." #: src/concurrency/async-control-flow/select.md:72 msgid "" "An alternative is to pass `&mut future` instead of the future itself, but " "this can lead to issues, further discussed in the pinning slide." msgstr "" +"یک راه جایگزین این است که به جای خودِ future از `&mut future` استفاده کنید، " +"اما این کار می‌تواند منجر به مسائلی شود که بیشتر در اسلاید سنجاق (pinning " +"slide) شده بحث شده است." #: src/concurrency/async-pitfalls.md msgid "" @@ -19657,6 +19798,10 @@ msgid "" "with its share of pitfalls and footguns. We illustrate some of them in this " "chapter." msgstr "" +"‏ Async / await انتزاع راحت و کارآمدی را برای برنامه نویسی concurrent " +"asynchronous فراهم می‌کند. با‌این‌حال، مدل async/wait در Rust نیز با سهم خود از " +"مشکلات و pitfallها و footgunها همراه است. برخی از آنها را در این فصل توضیح " +"می‌دهیم." #: src/concurrency/async-pitfalls.md msgid "Pin" @@ -19664,7 +19809,7 @@ msgstr "Pin" #: src/concurrency/async-pitfalls/blocking-executor.md:1 msgid "Blocking the executor" -msgstr "" +msgstr "مسدود کردن executor" #: src/concurrency/async-pitfalls/blocking-executor.md:3 msgid "" @@ -19673,20 +19818,28 @@ msgid "" "being executed. An easy workaround is to use async equivalent methods where " "possible." msgstr "" +"اکثر async runtimeهای تنها به IO task اجازه می‌دهند که به صورت همزمان " +"(concurrent) اجرا شوند. این بدان معنی است که تسک‌های block کردن CPU باعث " +"مسدود شدن executor و جلوگیری از اجرای سایر تسک‌ها می‌شود. یک راه حل آسان این " +"است که در صورت امکان از متدهای معادل async استفاده کنید." #: src/concurrency/async-pitfalls/blocking-executor.md:14 +#, fuzzy msgid "\"future {id} slept for {duration_ms}ms, finished after {}ms\"" -msgstr "" +msgstr "\"future {id} slept for {duration_ms}ms, finished after {}ms\"" #: src/concurrency/async-pitfalls/blocking-executor.md:19 +#, fuzzy msgid "\"current_thread\"" -msgstr "" +msgstr "\"current_thread\"" #: src/concurrency/async-pitfalls/blocking-executor.md:30 msgid "" "Run the code and see that the sleeps happen consecutively rather than " "concurrently." msgstr "" +"کد را اجرا کنید و ببینید که sleep‌ها به طور متوالی اتفاق می‌افتند و نه به صورت " +"همزمان (concurrent)." #: src/concurrency/async-pitfalls/blocking-executor.md:33 msgid "" @@ -19694,17 +19847,24 @@ msgid "" "makes the effect more obvious, but the bug is still present in the multi-" "threaded flavor." msgstr "" +"این `\"current_thread\"` همه taskها را روی یک thread قرار می‌دهد. این " +"اثرگذاری را آشکارتر می‌کند، اما این اشکال همچنان در طبیعت multi-threaded وجود " +"دارد." #: src/concurrency/async-pitfalls/blocking-executor.md:37 msgid "" "Switch the `std::thread::sleep` to `tokio::time::sleep` and await its result." msgstr "" +"‏ `std::thread::sleep` را به `tokio::time::sleep` تغییر دهید و منتظر نتیجه " +"باشید." #: src/concurrency/async-pitfalls/blocking-executor.md:39 msgid "" "Another fix would be to `tokio::task::spawn_blocking` which spawns an actual " "thread and transforms its handle into a future without blocking the executor." msgstr "" +"راه‌حل دیگر `tokio::task::spawn_blocking` است که یک thread واقعی ایجاد می‌کند " +"و handle آن را بدون مسدود کردن executor به future تبدیل می‌کند." #: src/concurrency/async-pitfalls/blocking-executor.md:42 msgid "" @@ -19715,12 +19875,21 @@ msgid "" "OS threads (e.g., CUDA). Prefer `tokio::task::spawn_blocking` in such " "situations." msgstr "" +"شما نباید taskها را به عنوان thread‌های سیستم عامل در نظر بگیرید. آنها از " +"نگاشت ۱ به ۱ پشتیبانی نمی‌کنند و اکثر executorها به بسیاری از taskها اجازه " +"می‌دهند روی یک thread سیستم عامل اجرا شوند. این امر به‌ویژه هنگام تعامل با " +"کتابخانه‌های دیگر از طریق FFI مشکل‌ساز است، جایی که آن کتابخانه ممکن است به " +"ذخیره‌سازی محلی thread یا نگاشت (map) به threadهای سیستم‌عامل خاص (مانند CUDA) " +"بستگی داشته باشد. در چنین شرایطی `tokio::task::spawn_blocking` را ترجیح دهید." #: src/concurrency/async-pitfalls/blocking-executor.md:48 msgid "" "Use sync mutexes with care. Holding a mutex over an `.await` may cause " "another task to block, and that task may be running on the same thread." msgstr "" +"با احتیاط از همگام‌سازی mutexها استفاده کنید. نگه داشتن یک mutex روی یک `." +"await` ممکن است باعث مسدود شدن task دیگری شود و آن task ممکن است در همان " +"thread در حال اجرا باشد." #: src/concurrency/async-pitfalls/pin.md:3 msgid "" @@ -19728,6 +19897,9 @@ msgid "" "type returned is the result of a compiler transformation which turns local " "variables into data stored inside the future." msgstr "" +"بلوک‌ها و توابع Async انواعی را برمی‌گردانند که ویژگی `Future` را پیاده‌سازی " +"می‌کنند. نوع برگشتی نتیجه تبدیل کامپایلر است که متغیرهای محلی را به داده های " +"ذخیره شده در future تبدیل می کند." #: src/concurrency/async-pitfalls/pin.md:7 msgid "" @@ -19735,6 +19907,9 @@ msgid "" "of that, the future should never be moved to a different memory location, as " "it would invalidate those pointers." msgstr "" +"برخی از این متغیرها می‌توانند اشاره‌گرهایی را برای سایر متغیرهای محلی نگه " +"دارند. به همین دلیل، future هرگز نباید به مکان حافظه دیگری منتقل شود، زیرا " +"این pointerها را باطل می‌کند." #: src/concurrency/async-pitfalls/pin.md:11 msgid "" @@ -19743,74 +19918,99 @@ msgid "" "operations that would move the instance it points to into a different memory " "location." msgstr "" +"برای جلوگیری از جابجایی تایپ future در حافظه، فقط از طریق یک pointer پین شده " +"می توان آن را بررسی کرد. `Pin` یک wrapper در اطراف یک reference است که تمام " +"عملیاتی را که می‌تواند نمونه‌ای را که به آن اشاره می‌کند به یک مکان حافظه " +"متفاوت منتقل کند را ممنوع می‌کند." #: src/concurrency/async-pitfalls/pin.md:20 +#, fuzzy msgid "" "// A work item. In this case, just sleep for the given time and respond\n" "// with a message on the `respond_on` channel.\n" msgstr "" +"// A work item. In this case, just sleep for the given time and respond\n" +"// with a message on the `respond_on` channel.\n" #: src/concurrency/async-pitfalls/pin.md:28 +#, fuzzy msgid "// A worker which listens for work on a queue and performs it.\n" -msgstr "" +msgstr "// A worker which listens for work on a queue and performs it.\n" #: src/concurrency/async-pitfalls/pin.md:35 +#, fuzzy msgid "// Pretend to work.\n" -msgstr "" +msgstr "// Pretend to work.\n" #: src/concurrency/async-pitfalls/pin.md:38 +#, fuzzy msgid "\"failed to send response\"" -msgstr "" +msgstr "\"failed to send response\"" #: src/concurrency/async-pitfalls/pin.md:41 +#, fuzzy msgid "// TODO: report number of iterations every 100ms\n" -msgstr "" +msgstr "// TODO: report number of iterations every 100ms\n" #: src/concurrency/async-pitfalls/pin.md:45 +#, fuzzy msgid "// A requester which requests work and waits for it to complete.\n" -msgstr "" +msgstr "// A requester which requests work and waits for it to complete.\n" #: src/concurrency/async-pitfalls/pin.md:52 +#, fuzzy msgid "\"failed to send on work queue\"" -msgstr "" +msgstr "\"failed to send on work queue\"" #: src/concurrency/async-pitfalls/pin.md:53 +#, fuzzy msgid "\"failed waiting for response\"" -msgstr "" +msgstr "\"failed waiting for response\"" #: src/concurrency/async-pitfalls/pin.md:62 +#, fuzzy msgid "\"work result for iteration {i}: {resp}\"" -msgstr "" +msgstr "\"Welcome to chat! Type a message\"" #: src/concurrency/async-pitfalls/pin.md:70 msgid "" "You may recognize this as an example of the actor pattern. Actors typically " "call `select!` in a loop." msgstr "" +"شما ممکن است این را به عنوان نمونه ای از الگوی بازیگر (actor pattern) تشخیص " +"دهید. بازیگران معمولاً `select!` را در یک حلقه صدا می‌زنند." #: src/concurrency/async-pitfalls/pin.md:73 msgid "" "This serves as a summation of a few of the previous lessons, so take your " "time with it." msgstr "" +"این به عنوان یک جمع‌بندی از چند درس قبلی عمل می کند، بنابراین وقت خود را صرف " +"آن کنید." #: src/concurrency/async-pitfalls/pin.md:76 msgid "" "Naively add a `_ = sleep(Duration::from_millis(100)) => { println!(..) }` to " "the `select!`. This will never execute. Why?" msgstr "" +"به‌سادگی یک `_ = sleep(Duration::from_millis(100)) => { println!(..) }` را به " +"`select!` اضافه کنید. این مورد هرگز اجرا نمی شود. چرا؟" #: src/concurrency/async-pitfalls/pin.md:79 msgid "" "Instead, add a `timeout_fut` containing that future outside of the `loop`:" -msgstr "" +msgstr "درعوض، یک `timeout_fut` حاوی آن future خارج از `loop` اضافه کنید:" #: src/concurrency/async-pitfalls/pin.md:90 +#, fuzzy msgid "" "This still doesn't work. Follow the compiler errors, adding `&mut` to the " "`timeout_fut` in the `select!` to work around the move, then using `Box::" "pin`:" msgstr "" +"این مورد هنوز کار نمی‌کند. خطاهای کامپایلر را دنبال کنید، `&mut` را به " +"`timeout_fut` در `select!` اضافه کنید تا حرکت را ادامه دهید، سپس از `Box::" +"pin` استفاده کنید:" #: src/concurrency/async-pitfalls/pin.md:104 msgid "" @@ -19818,19 +20018,29 @@ msgid "" "iteration (a fused future would help with this). Update to reset " "`timeout_fut` every time it expires:" msgstr "" +"این مورد کامپایل می‌شود، اما پس از انقضای timeout و در هر تکرار برابر با " +"`Poll::Ready` است (future ترکیبی به این مسئله کمک می‌کند). به‌روزرسانی برای " +"بازنشانی `timeout_fut` هر بار که منقضی می‌شود:" #: src/concurrency/async-pitfalls/pin.md:119 +#, fuzzy msgid "" "Box allocates on the heap. In some cases, `std::pin::pin!` (only recently " "stabilized, with older code often using `tokio::pin!`) is also an option, " "but that is difficult to use for a future that is reassigned." msgstr "" +"جعبه allocateها بر روی heap. در برخی موارد، `std::pin::pin!` (فقط به تازگی " +"تثبیت شده است، با کدهای قدیمی‌تر که اغلب از `tokio::pin!` استفاده می‌کنند) نیز " +"یک گزینه است، اما استفاده از آن برای futureای که دوباره تخصیص داده می‌شود " +"دشوار است." #: src/concurrency/async-pitfalls/pin.md:123 msgid "" "Another alternative is to not use `pin` at all but spawn another task that " "will send to a `oneshot` channel every 100ms." msgstr "" +"جایگزین دیگر این است که به هیچ وجه از `pin` استفاده نکنید، بلکه task دیگری " +"ایجاد کنید که هر 100 میلی‌ثانیه به یک کانال `oneshot` ارسال می‌شود." #: src/concurrency/async-pitfalls/pin.md:126 msgid "" @@ -19840,6 +20050,11 @@ msgid "" "code transformation for async blocks and functions is not verified by the " "borrow checker." msgstr "" +"داده‌هایی که حاوی اشاره‌گرهایی به خود هستند، خود ارجاعی ( self-referential) " +"نامیده می شوند. به طور معمول، Rust borrow checker از جابجایی داده‌های " +"خودارجاعی جلوگیری می‌کند، زیرا منابع نمی‌توانند بیشتر از داده‌هایی که به آنها " +"اشاره می‌کنند زنده بمانند. با‌این‌حال، تبدیل کد برای بلوک‌ها و توابع async توسط " +"borrow checker تأیید نمی‌شود." #: src/concurrency/async-pitfalls/pin.md:132 msgid "" @@ -19847,6 +20062,9 @@ msgid "" "place using a pinned pointer. However, it can still be moved through an " "unpinned pointer." msgstr "" +"‏ `Pin` یک wrapper در اطراف یک reference است. یک object را نمی‌توان با استفاده " +"از یک pointer پین شده از جای خود حرکت داد. با این حال، هنوز هم می‌توان آن را " +"از طریق یک pointer بدون پین جابجا کرد." #: src/concurrency/async-pitfalls/pin.md:136 msgid "" @@ -19854,6 +20072,9 @@ msgid "" "`&mut Self` to refer to the instance. That's why it can only be called on a " "pinned pointer." msgstr "" +"متد `poll` از ویژگی `Future` از `Pin<&mut Self>` به جای `&mut Self` برای " +"اشاره به نمونه (instance) استفاده می‌‌کند. به همین دلیل است که فقط می‌توان آن " +"را روی یک اشاره‌‌گر پین شده فراخوانی کرد." #: src/concurrency/async-pitfalls/async-traits.md:3 msgid "" @@ -19862,45 +20083,64 @@ msgid "" "in traits, as the desugaring for `async fn` includes `-> impl Future`." msgstr "" +"متدهای Async در traitها اخیراً در انتشار 1.75 تثبیت شده‌اند. این نیاز به " +"پشتیبانی برای استفاده از موقعیت بازگشتی `impl Trait` (RPIT) در traitها را " +"داشت، زیرا شیرین‌زدایی (desugaring) برای `async fn` شامل `-> impl " +"Future` است." #: src/concurrency/async-pitfalls/async-traits.md:7 msgid "" "However, even with the native support today there are some pitfalls around " "`async fn` and RPIT in traits:" msgstr "" +"با این‌حال، حتی با پشتیبانی native امروز، برخی از مشکلات در مورد `async fn` و " +"RPIT در ویژگی‌ها وجود دارد:" #: src/concurrency/async-pitfalls/async-traits.md:10 msgid "" "Return-position impl Trait captures all in-scope lifetimes (so some patterns " "of borrowing cannot be expressed)" msgstr "" +"‏Return-position impl Trait تمام طول عمرهای درون محدوده را ثبت می کند " +"(بنابراین برخی از الگوهای قرض کردن (borrowing) نمی توانند بیان شوند)" #: src/concurrency/async-pitfalls/async-traits.md:13 msgid "" "Traits whose methods use return-position `impl trait` or `async` are not " "`dyn` compatible." msgstr "" +"ویژگی‌هایی که متد‌های آن‌ها از موقعیت بازگشتی `impl trait` یا `async` استفاده " +"می‌کنند با `dyn` سازگار نیستند." #: src/concurrency/async-pitfalls/async-traits.md:16 +#, fuzzy msgid "" "If we do need `dyn` support, the crate [async_trait](https://docs.rs/async-" "trait/latest/async_trait/) provides a workaround through a macro, with some " "caveats:" msgstr "" +"اگر به پشتیبانی `dyn` نیاز داریم، crate [async_trait](https://docs.rs/async-" +"trait/latest/async_trait/) راه‌حلی را از طریق یک ماکرو ارائه می‌کند، با ذکر " +"چند نکته:" #: src/concurrency/async-pitfalls/async-traits.md:46 +#, fuzzy msgid "\"running all sleepers..\"" -msgstr "" +msgstr "\"running all sleepers..\"" #: src/concurrency/async-pitfalls/async-traits.md:50 +#, fuzzy msgid "\"slept for {}ms\"" -msgstr "" +msgstr "\"slept for {}ms\"" #: src/concurrency/async-pitfalls/async-traits.md:68 msgid "" "`async_trait` is easy to use, but note that it's using heap allocations to " "achieve this. This heap allocation has performance overhead." msgstr "" +"استفاده از `async_trait` آسان است، اما توجه داشته باشید که برای رسیدن به این " +"هدف از heap allocationها استفاده می‌کند. این heap allocation دارای سربار " +"عملکرد است." #: src/concurrency/async-pitfalls/async-traits.md:71 msgid "" @@ -19910,12 +20150,19 @@ msgid "" "blog/2019/10/26/async-fn-in-traits-are-hard/) if you are interested in " "digging deeper." msgstr "" +"چالش‌های پشتیبانی برای `async trait` در زبان Rust بسیار عمیق هستند و احتمالاً " +"ارزش توصیف عمیق در اینجا را ندارند. Niko Matsakis در [این پست](https://" +"smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-" +"hard/) آنها را به خوبی توضیح داده است. به خصوص اگر شما به این موضوع علاقه‌مند " +"هستید." #: src/concurrency/async-pitfalls/async-traits.md:77 msgid "" "Try creating a new sleeper struct that will sleep for a random amount of " "time and adding it to the Vec." msgstr "" +"سعی کنید یک sleep خواب جدید ایجاد کنید که برای مدت زمان تصادفی می‌خوابد و آن " +"را به Vec اضافه کنید." #: src/concurrency/async-pitfalls/cancellation.md:3 msgid "" @@ -19924,51 +20171,64 @@ msgid "" "ensure the system works correctly even when futures are cancelled. For " "example, it shouldn't deadlock or lose data." msgstr "" +"کنار گذاشتن future به این معنی است که دیگر هرگز نمی‌توان آن را poll کرد. به " +"این حالت _cancellation_ می‌گویند و می‌تواند در هر نقطه `await` رخ دهد. برای " +"اطمینان از عملکرد صحیح سیستم حتی در صورت لغو futureها، دقت مناسب لازم است. " +"به‌عنوان ‌مثال، نباید داده‌ها را از دست بدهد یا به بن‌بست (deadlock) برسد." #: src/concurrency/async-pitfalls/cancellation.md:35 #: src/concurrency/async-pitfalls/cancellation.md:102 +#, fuzzy msgid "\"not UTF-8\"" -msgstr "" +msgstr "\"not UTF-8\"" #: src/concurrency/async-pitfalls/cancellation.md:51 +#, fuzzy msgid "\"hi\\nthere\\n\"" -msgstr "" +msgstr "\"hi\\nthere\\n\"" #: src/concurrency/async-pitfalls/cancellation.md:57 +#, fuzzy msgid "\"tick!\"" -msgstr "" +msgstr "\"tick!\"" #: src/concurrency/async-pitfalls/cancellation.md:73 msgid "" "The compiler doesn't help with cancellation-safety. You need to read API " "documentation and consider what state your `async fn` holds." msgstr "" +"کامپایلر در مورد cancellation-safety کمکی نمی‌کند. باید مستندات API را " +"بخوانید و در نظر بگیرید که `async fn` شما چه وضعیتی دارد." #: src/concurrency/async-pitfalls/cancellation.md:76 msgid "" "Unlike `panic` and `?`, cancellation is part of normal control flow (vs " "error-handling)." msgstr "" +"برخلاف `panic` و `?`، لغو یا cancellation بخشی از جریان کنترل عادی (و رسیدگی " +"به خطا) است." #: src/concurrency/async-pitfalls/cancellation.md:79 msgid "The example loses parts of the string." -msgstr "" +msgstr "اسن مثال بخش‌هایی از string را از دست می‌دهد." #: src/concurrency/async-pitfalls/cancellation.md:81 msgid "" "Whenever the `tick()` branch finishes first, `next()` and its `buf` are " "dropped." msgstr "" +"هر زمان که شاخه `tick()` اول تمام شود، `next()` و `buf` آن حذف می شوند." #: src/concurrency/async-pitfalls/cancellation.md:84 msgid "" "`LinesReader` can be made cancellation-safe by making `buf` part of the " "struct:" -msgstr "" +msgstr "‏`LinesReader` را می‌توان با تبدیل `buf` به بخشی از ساختار، ایمن کرد:" #: src/concurrency/async-pitfalls/cancellation.md:98 +#, fuzzy msgid "// prefix buf and bytes with self.\n" -msgstr "" +msgstr "// prefix buf and bytes with self.\n" #: src/concurrency/async-pitfalls/cancellation.md:108 msgid "" @@ -19976,6 +20236,9 @@ msgid "" "html#method.tick) is cancellation-safe because it keeps track of whether a " "tick has been 'delivered'." msgstr "" +"‏ ['Interval::tick'](https://docs.rs/tokio/latest/tokio/time/struct.Interval." +"html#method.tick) برای cancellation-safe است زیرا ردیابی می‌کند که آیا یک " +"tick تحویل داده شده است." #: src/concurrency/async-pitfalls/cancellation.md:112 msgid "" @@ -19983,6 +20246,9 @@ msgid "" "AsyncReadExt.html#method.read) is cancellation-safe because it either " "returns or doesn't read data." msgstr "" +"‏ [`AsyncReadExt::read`](https://docs.rs/tokio/latest/tokio/io/trait." +"AsyncReadExt.html#method.read) برای cancellation-safe است زیرا داده‌ها را " +"برمی‌گرداند یا نمی‌خواند." #: src/concurrency/async-pitfalls/cancellation.md:115 msgid "" @@ -19990,18 +20256,23 @@ msgid "" "AsyncBufReadExt.html#method.read_line) is similar to the example and _isn't_ " "cancellation-safe. See its documentation for details and alternatives." msgstr "" +"‏ [`AsyncBufReadExt::read_line`](https://docs.rs/tokio/latest/tokio/io/trait." +"AsyncBufReadExt.html#method.read_line) مشابه مثال است و شبیه cancellation-" +"safe نیست. برای جزئیات و موارد جایگزین به مستندات آن مراجعه کنید." #: src/concurrency/async-exercises/dining-philosophers.md:1 #: src/concurrency/async-exercises/solutions.md:3 #, fuzzy msgid "Dining Philosophers --- Async" -msgstr "فلسفه Dining" +msgstr "فلسفه Dining --- Async" #: src/concurrency/async-exercises/dining-philosophers.md:3 msgid "" "See [dining philosophers](../sync-exercises/dining-philosophers.md) for a " "description of the problem." msgstr "" +"برای توضیح مشکل به [dining philosophers](../sync-exercises/dining-" +"philosophers.md) مراجعه کنید." #: src/concurrency/async-exercises/dining-philosophers.md:6 msgid "" @@ -20009,22 +20280,29 @@ msgid "" "locally.md) for this exercise. Copy the code below to a file called `src/" "main.rs`, fill out the blanks, and test that `cargo run` does not deadlock:" msgstr "" +"مانند قبل، برای این تمرین به Cargo installation](../../cargo/running-locally." +"md) نیاز دارید. کد زیر را در فایلی به نام `src/main.rs` کپی کنید، جاهای خالی " +"را پر کنید و تست کنید که `cargo run` به بن بست (`src/main.rs`) نمی‌خورد:" #: src/concurrency/async-exercises/dining-philosophers.md:37 #: src/concurrency/async-exercises/solutions.md:29 +#, fuzzy msgid "// Keep trying until we have both forks\n" -msgstr "" +msgstr "// Keep trying until we have both forks\n" #: src/concurrency/async-exercises/dining-philosophers.md:52 #: src/concurrency/async-exercises/solutions.md:85 +#, fuzzy msgid "// Make them think and eat\n" -msgstr "" +msgstr "// Make them think and eat\n" #: src/concurrency/async-exercises/dining-philosophers.md:58 msgid "" "Since this time you are using Async Rust, you'll need a `tokio` dependency. " "You can use the following `Cargo.toml`:" msgstr "" +"از آنجایی که این بار از Async Rust استفاده می‌کنید، به وابستگی `tokio` نیاز " +"دارید. می‌توانید از `Cargo.toml` زیر استفاده کنید:" #: src/concurrency/async-exercises/dining-philosophers.md:63 msgid "" @@ -20039,16 +20317,28 @@ msgid "" "\"rt-multi-thread\"] }\n" "```" msgstr "" +"```toml\n" +"[package]\n" +"name = \"dining-philosophers-async-dine\"\n" +"version = \"0.1.0\"\n" +"edition = \"2021\"\n" +"\n" +"[dependencies]\n" +"tokio = { version = \"1.26.0\", features = [\"sync\", \"time\", \"macros\", " +"\"rt-multi-thread\"] }\n" +"```" #: src/concurrency/async-exercises/dining-philosophers.md:73 msgid "" "Also note that this time you have to use the `Mutex` and the `mpsc` module " "from the `tokio` crate." msgstr "" +"همچنین توجه داشته باشید که این بار باید از ماژول `Mutex` و `mpsc` از `tokio` " +"crate استفاده کنید." #: src/concurrency/async-exercises/dining-philosophers.md:79 msgid "Can you make your implementation single-threaded?" -msgstr "" +msgstr "آیا می‌توانید پیاده‌سازی خود را تک thread ای کنید؟" #: src/concurrency/async-exercises/chat-app.md:3 msgid "" @@ -20058,6 +20348,11 @@ msgid "" "input, and sends them to the server. The chat server broadcasts each message " "that it receives to all the clients." msgstr "" +"در این تمرین، ما می‌خواهیم از دانش جدید خود برای پیاده سازی یک برنامه " +"broadcast chat استفاده کنیم. ما یک سرور چت داریم که کاربران به آن متصل " +"می‌شوند و پیام‌های خود را منتشر می‌کنند. کلاینت پیام‌های کاربر را از ورودی " +"استاندارد می‌خواند و آنها را به سرور ارسال می‌کند. سرور چت هر پیامی را که " +"دریافت می‌کند برای همه کاربران پخش می‌کند." #: src/concurrency/async-exercises/chat-app.md:9 msgid "" @@ -20066,14 +20361,17 @@ msgid "" "(https://docs.rs/tokio-websockets/) for the communication between the client " "and the server." msgstr "" +"برای این کار، از [ broadcast channel](https://docs.rs/tokio/latest/tokio/" +"sync/broadcast/fn.channel.html) در سمت سرور و [`tokio_websockets`](https://" +"docs.rs/tokio-websockets/) برای ارتباط بین کلاینت و سرور." #: src/concurrency/async-exercises/chat-app.md:12 msgid "Create a new Cargo project and add the following dependencies:" -msgstr "" +msgstr "یک پروژه Cargo جدید ایجاد کنید و وابستگی‌های زیر را اضافه کنید:" #: src/concurrency/async-exercises/chat-app.md:14 msgid "_Cargo.toml_:" -msgstr "" +msgstr "_Cargo.toml_:" #: src/concurrency/async-exercises/chat-app.md:18 msgid "" @@ -20091,10 +20389,23 @@ msgid "" "\"fastrand\", \"server\", \"sha1_smol\"] }\n" "```" msgstr "" +"```toml\n" +"[package]\n" +"name = \"chat-async\"\n" +"version = \"0.1.0\"\n" +"edition = \"2021\"\n" +"\n" +"[dependencies]\n" +"futures-util = { version = \"0.3.30\", features = [\"sink\"] }\n" +"http = \"1.1.0\"\n" +"tokio = { version = \"1.38.1\", features = [\"full\"] }\n" +"tokio-websockets = { version = \"0.8.3\", features = [\"client\", " +"\"fastrand\", \"server\", \"sha1_smol\"] }\n" +"```" #: src/concurrency/async-exercises/chat-app.md:31 msgid "The required APIs" -msgstr "" +msgstr "‏API‌های مورد نیاز" #: src/concurrency/async-exercises/chat-app.md:33 msgid "" @@ -20102,6 +20413,8 @@ msgid "" "[`tokio_websockets`](https://docs.rs/tokio-websockets/). Spend a few minutes " "to familiarize yourself with the API." msgstr "" +"شما به توابع زیر از `tokio` و [`tokio_websockets`](https://docs.rs/tokio-" +"websockets/) نیاز دارید. چند دقیقه را برای آشنایی با API اختصاص دهید." #: src/concurrency/async-exercises/chat-app.md:37 msgid "" @@ -20109,6 +20422,9 @@ msgid "" "trait.StreamExt.html#method.next) implemented by `WebSocketStream`: for " "asynchronously reading messages from a Websocket Stream." msgstr "" +"‏ [StreamExt::next()](https://docs.rs/futures-util/0.3.28/futures_util/stream/" +"trait.StreamExt.html#method.next) توسط `WebSocketStream`: برای خواندن " +"ناهمزمان پیام‌ها از یک جریان وب سوکت." #: src/concurrency/async-exercises/chat-app.md:39 msgid "" @@ -20116,6 +20432,9 @@ msgid "" "trait.SinkExt.html#method.send) implemented by `WebSocketStream`: for " "asynchronously sending messages on a Websocket Stream." msgstr "" +"‏[SinkExt::send()](https://docs.rs/futures-util/0.3.28/futures_util/sink/" +"trait.SinkExt.html#method.send) پیاده‌سازی شده توسط `WebSocketStream`: برای " +"ارسال ناهمزمان پیام‌ها در یک Websocket Stream." #: src/concurrency/async-exercises/chat-app.md:41 msgid "" @@ -20123,16 +20442,21 @@ msgid "" "html#method.next_line): for asynchronously reading user messages from the " "standard input." msgstr "" +"‏[Lines::next_line()](https://docs.rs/tokio/latest/tokio/io/struct.Lines." +"html#method.next_line): برای خواندن ناهمزمان پیام‌های کاربر از ورودی " +"استاندارد." #: src/concurrency/async-exercises/chat-app.md:43 msgid "" "[Sender::subscribe()](https://docs.rs/tokio/latest/tokio/sync/broadcast/" "struct.Sender.html#method.subscribe): for subscribing to a broadcast channel." msgstr "" +"‏[Sender::subscribe()](https://docs.rs/tokio/latest/tokio/sync/broadcast/" +"struct.Sender.html#method.subscribe): برای اشتراک در یک broadcast channel." #: src/concurrency/async-exercises/chat-app.md:45 msgid "Two binaries" -msgstr "" +msgstr "دو باینری" #: src/concurrency/async-exercises/chat-app.md:47 msgid "" @@ -20144,6 +20468,13 @@ msgid "" "(see the [documentation](https://doc.rust-lang.org/cargo/reference/cargo-" "targets.html#binaries))." msgstr "" +"به طور معمول در یک پروژه Cargo، شما می توانید فقط یک فایل باینری و یک فایل " +"`src/main.rs` داشته باشید. در این پروژه به دو باینری نیاز داریم. یکی برای " +"کلاینت و دیگری برای سرور. شما به طور بالقوه می‌توانید آنها را در دو پروژه " +"Cargo جداگانه بسازید، اما ما آنها را در یک پروژه Cargo واحد با دو باینری " +"قرار می‌دهیم. برای این کار، کلاینت و کد سرور باید زیر `src/bin` قرار گیرند " +"(به[documentation](https://doc.rust-lang.org/cargo/reference/cargo-targets." +"html#binaries) مراجعه کنید )." #: src/concurrency/async-exercises/chat-app.md:54 msgid "" @@ -20151,62 +20482,70 @@ msgid "" "bin/client.rs`, respectively. Your task is to complete these files as " "described below." msgstr "" +"کد سرور و کلاینت زیر را به ترتیب در`src/bin/server.rs` و `src/bin/client.rs` " +"کپی کنید. وظیفه شما این است که این فایل‌ها را همانطور که در زیر توضیح داده " +"شده است تکمیل کنید." #: src/concurrency/async-exercises/chat-app.md:58 #: src/concurrency/async-exercises/solutions.md:104 msgid "_src/bin/server.rs_:" -msgstr "" +msgstr "_src/bin/server.rs_:" #: src/concurrency/async-exercises/chat-app.md:77 #: src/concurrency/async-exercises/chat-app.md:124 +#, fuzzy msgid "// TODO: For a hint, see the description of the task below.\n" -msgstr "" +msgstr "// TODO: For a hint, see the description of the task below.\n" #: src/concurrency/async-exercises/chat-app.md:85 #: src/concurrency/async-exercises/solutions.md:154 msgid "\"127.0.0.1:2000\"" -msgstr "" +msgstr "\"127.0.0.1:2000\"" #: src/concurrency/async-exercises/chat-app.md:86 #: src/concurrency/async-exercises/solutions.md:155 +#, fuzzy msgid "\"listening on port 2000\"" -msgstr "" +msgstr "\"listening on port 2000\"" #: src/concurrency/async-exercises/chat-app.md:90 #: src/concurrency/async-exercises/solutions.md:159 +#, fuzzy msgid "\"New connection from {addr:?}\"" -msgstr "" +msgstr "\"New connection from {addr:?}\"" #: src/concurrency/async-exercises/chat-app.md:93 #: src/concurrency/async-exercises/solutions.md:162 +#, fuzzy msgid "// Wrap the raw TCP stream into a websocket.\n" -msgstr "" +msgstr "// Wrap the raw TCP stream into a websocket.\n" #: src/concurrency/async-exercises/chat-app.md:102 #: src/concurrency/async-exercises/solutions.md:171 msgid "_src/bin/client.rs_:" -msgstr "" +msgstr "_src/bin/client.rs_:" #: src/concurrency/async-exercises/chat-app.md:116 #: src/concurrency/async-exercises/solutions.md:183 +#, fuzzy msgid "\"ws://127.0.0.1:2000\"" -msgstr "" +msgstr "\"ws://127.0.0.1:2000\"" #: src/concurrency/async-exercises/chat-app.md:129 msgid "Running the binaries" -msgstr "" +msgstr "راه‌اندازی باینری" #: src/concurrency/async-exercises/chat-app.md:131 msgid "Run the server with:" -msgstr "" +msgstr "سرور را راه‌اندازی کنید با استفاده از:" #: src/concurrency/async-exercises/chat-app.md:137 msgid "and the client with:" -msgstr "" +msgstr "و این کلاینت با:" #: src/concurrency/async-exercises/chat-app.md:145 msgid "Implement the `handle_connection` function in `src/bin/server.rs`." -msgstr "" +msgstr "تابع `handle_connection` را در `src/bin/server.rs` پیاده‌سازی کنید." #: src/concurrency/async-exercises/chat-app.md:146 msgid "" @@ -20214,10 +20553,14 @@ msgid "" "continuous loop. One task receives messages from the client and broadcasts " "them. The other sends messages received by the server to the client." msgstr "" +"نکته: از `tokio::select!` برای انجام همزمان دو task در یک حلقه پیوسته " +"استفاده کنید. یک task پیام‌هایی را از کلاینت دریافت می‌کند و آنها را " +"پخش(broadcast) می‌کند. دیگری پیام‌های دریافت شده توسط سرور را برای کاربر ارسال " +"می‌کند." #: src/concurrency/async-exercises/chat-app.md:149 msgid "Complete the main function in `src/bin/client.rs`." -msgstr "" +msgstr "تابع اصلی را در `src/bin/client.rs` تکمیل کنید." #: src/concurrency/async-exercises/chat-app.md:150 msgid "" @@ -20226,59 +20569,81 @@ msgid "" "sending them to the server, and (2) receiving messages from the server, and " "displaying them for the user." msgstr "" +"نکته: مانند قبل، از `tokio::select!` در یک حلقه پیوسته برای انجام همزمان دو " +"task استفاده کنید: (۱) خواندن پیام های کاربر از ورودی استاندارد و ارسال آنها " +"به سرور و (۲) دریافت پیام از سرور و نمایش آنها برای کاربر." #: src/concurrency/async-exercises/chat-app.md:154 msgid "" "Optional: Once you are done, change the code to broadcast messages to all " "clients, but the sender of the message." msgstr "" +"اختیاری: پس از اتمام کار، کد را تغییر دهید تا پیام‌ها برای همه کلاینت‌ها، به " +"جز فرستنده پیام، منتشر شود." #: src/concurrency/async-exercises/solutions.md:35 +#, fuzzy msgid "" "// If we didn't get the left fork, drop the right fork if we\n" " // have it and let other tasks make progress.\n" msgstr "" +"// If we didn't get the left fork, drop the right fork if we\n" +" // have it and let other tasks make progress.\n" #: src/concurrency/async-exercises/solutions.md:42 +#, fuzzy msgid "" "// If we didn't get the right fork, drop the left fork and let\n" " // other tasks make progress.\n" msgstr "" +"// If we didn't get the right fork, drop the left fork and let\n" +" // other tasks make progress.\n" #: src/concurrency/async-exercises/solutions.md:54 +#, fuzzy msgid "// The locks are dropped here\n" -msgstr "" +msgstr "// The locks are dropped here\n" #: src/concurrency/async-exercises/solutions.md:82 +#, fuzzy msgid "// tx is dropped here, so we don't need to explicitly drop it later\n" -msgstr "" +msgstr "// tx is dropped here, so we don't need to explicitly drop it later\n" #: src/concurrency/async-exercises/solutions.md:97 +#, fuzzy msgid "\"Here is a thought: {thought}\"" -msgstr "" +msgstr "\"Here is a thought: {thought}\"" #: src/concurrency/async-exercises/solutions.md:122 +#, fuzzy msgid "\"Welcome to chat! Type a message\"" -msgstr "" +msgstr "\"Welcome to chat! Type a message\"" #: src/concurrency/async-exercises/solutions.md:126 +#, fuzzy msgid "" "// A continuous loop for concurrently performing two tasks: (1) receiving\n" " // messages from `ws_stream` and broadcasting them, and (2) receiving\n" " // messages on `bcast_rx` and sending them to the client.\n" msgstr "" +"// A continuous loop for concurrently performing two tasks: (1) receiving\n" +" // messages from `ws_stream` and broadcasting them, and (2) receiving\n" +" // messages on `bcast_rx` and sending them to the client.\n" #: src/concurrency/async-exercises/solutions.md:135 +#, fuzzy msgid "\"From client {addr:?} {text:?}\"" -msgstr "" +msgstr "\"From client {addr:?} {text:?}\"" #: src/concurrency/async-exercises/solutions.md:190 +#, fuzzy msgid "// Continuous loop for concurrently sending and receiving messages.\n" -msgstr "" +msgstr "// Continuous loop for concurrently sending and receiving messages.\n" #: src/concurrency/async-exercises/solutions.md:197 +#, fuzzy msgid "\"From server: {}\"" -msgstr "" +msgstr "\"From server: {}\"" #: src/thanks.md msgid ""