//! Illustrates the feature of this library that lets you use the synchronous stdio functionality //! upon the async streams, with some trivial code adjustments. extern crate async_blocking_stdio as astdio; extern crate futures_lite; fn main() -> std::io::Result<()> { futures_lite::future::block_on(async { use std::io::Write; let mut stdout_sync_handle = astdio::stdout().lock_into_sync().await; // Note how we do not need to bother flushing this - it's auto-handled by the crate, and is // basically just println! here. // // However - in reality, this is not ideal because `BlockOn` uses // futures_lite::future::block_on internally - it's better to use the async traits // internally where possible if you're inside a future like this. writeln!(stdout_sync_handle, "Hello world, from sync!") }) } // async-blocking-stdio - std::io::std{in(), out(), err()}, but async // Copyright (C) 2024 Matti Bryce // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see .