### Yansi Paint Foreground Color Examples Source: https://docs.rs/taquba/0.9.0/taquba/struct.EnqueueRequest.html Examples demonstrating how to set foreground colors using the yansi Paint trait. ```rust use yansi::{Paint, Color}; painted.fg(Color::White); ``` ```rust use yansi::Paint; painted.white(); ``` ```rust println!("{}", value.primary()); ``` ```rust println!("{}", value.fixed(color)); ``` ```rust println!("{}", value.rgb(r, g, b)); ``` ```rust println!("{}", value.black()); ``` ```rust println!("{}", value.red()); ``` ```rust println!("{}", value.green()); ``` -------------------------------- ### Construct Box from raw pointer Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Examples demonstrating how to recreate a Box from a raw pointer or manually allocate memory for a Box. ```rust #![feature(allocator_api)] use std::alloc::System; let x = Box::new_in(5, System); let (ptr, alloc) = Box::into_raw_with_allocator(x); let x = unsafe { Box::from_raw_in(ptr, alloc) }; ``` ```rust #![feature(allocator_api, slice_ptr_get)] use std::alloc::{Allocator, Layout, System}; unsafe { let ptr = System.allocate(Layout::new::())?.as_mut_ptr() as *mut i32; // In general .write is required to avoid attempting to destruct // the (uninitialized) previous contents of `ptr`, though for this // simple example `*ptr = 5` would have worked as well. ptr.write(5); let x = Box::from_raw_in(ptr, System); } ``` -------------------------------- ### Allocating with custom allocators Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Examples of using new_in and try_new_in with the allocator_api feature. ```rust #![feature(allocator_api)] use std::alloc::System; let five = Box::new_in(5, System); ``` ```rust #![feature(allocator_api)] use std::alloc::System; ``` -------------------------------- ### Construct Box from NonNull pointer Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Examples demonstrating how to recreate a Box from a NonNull pointer or manually allocate memory for a Box. ```rust #![feature(allocator_api)] use std::alloc::System; let x = Box::new_in(5, System); let (non_null, alloc) = Box::into_non_null_with_allocator(x); let x = unsafe { Box::from_non_null_in(non_null, alloc) }; ``` ```rust #![feature(allocator_api)] use std::alloc::{Allocator, Layout, System}; unsafe { let non_null = System.allocate(Layout::new::())?.cast::(); // In general .write is required to avoid attempting to destruct // the (uninitialized) previous contents of `non_null`. non_null.write(5); let x = Box::from_non_null_in(non_null, System); } ``` -------------------------------- ### Construct Box from Raw Pointer Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Examples of creating a Box from a raw pointer using Box::from_raw. ```rust let x = Box::new(5); let ptr = Box::into_raw(x); let x = unsafe { Box::from_raw(ptr) }; ``` ```rust use std::alloc::{alloc, Layout}; unsafe { let ptr = alloc(Layout::new::()) as *mut i32; // In general .write is required to avoid attempting to destruct // the (uninitialized) previous contents of `ptr`, though for this // simple example `*ptr = 5` would have worked as well. ptr.write(5); let x = Box::from_raw(ptr); } ``` -------------------------------- ### Convert Box to Raw Pointer Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Examples of consuming a Box into a raw pointer and managing its cleanup. ```rust let x = Box::new(String::from("Hello")); let ptr = Box::into_raw(x); let x = unsafe { Box::from_raw(ptr) }; ``` ```rust use std::alloc::{dealloc, Layout}; use std::ptr; let x = Box::new(String::from("Hello")); let ptr = Box::into_raw(x); unsafe { ptr::drop_in_place(ptr); dealloc(ptr as *mut u8, Layout::new::()); } ``` ```rust let x = Box::new(String::from("Hello")); let ptr = Box::into_raw(x); unsafe { drop(Box::from_raw(ptr)); } ``` -------------------------------- ### Apply Quirk Methods Source: https://docs.rs/taquba/0.9.0/taquba/struct.QueueStats.html Examples of various quirk methods available for painted text. ```rust println!("{}", value.mask()); ``` ```rust println!("{}", value.wrap()); ``` ```rust println!("{}", value.linger()); ``` ```rust println!("{}", value.clear()); ``` ```rust println!("{}", value.resetting()); ``` ```rust println!("{}", value.bright()); ``` ```rust println!("{}", value.on_bright()); ``` -------------------------------- ### Print blue color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with a blue foreground color. ```rust println!("{}", value.blue()); ``` -------------------------------- ### Print cyan color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with a cyan foreground color. ```rust println!("{}", value.cyan()); ``` -------------------------------- ### Consume Box into raw pointer and allocator Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Demonstrates consuming a Box to retrieve its raw pointer and allocator, with examples for automatic and manual cleanup. ```rust #![feature(allocator_api)] use std::alloc::System; let x = Box::new_in(String::from("Hello"), System); let (ptr, alloc) = Box::into_raw_with_allocator(x); let x = unsafe { Box::from_raw_in(ptr, alloc) }; ``` ```rust #![feature(allocator_api)] use std::alloc::{Allocator, Layout, System}; use std::ptr::{self, NonNull}; let x = Box::new_in(String::from("Hello"), System); let (ptr, alloc) = Box::into_raw_with_allocator(x); unsafe { ptr::drop_in_place(ptr); let non_null = NonNull::new_unchecked(ptr); alloc.deallocate(non_null.cast(), Layout::new::()); } ``` -------------------------------- ### Print RGB color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with an RGB foreground color. ```rust println!("{}", value.rgb(r, g, b)); ``` -------------------------------- ### Consume Box into NonNull pointer and allocator Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Demonstrates consuming a Box to retrieve a NonNull pointer and allocator, with examples for automatic and manual cleanup. ```rust #![feature(allocator_api)] use std::alloc::System; let x = Box::new_in(String::from("Hello"), System); let (non_null, alloc) = Box::into_non_null_with_allocator(x); let x = unsafe { Box::from_non_null_in(non_null, alloc) }; ``` ```rust #![feature(allocator_api)] use std::alloc::{Allocator, Layout, System}; let x = Box::new_in(String::from("Hello"), System); let (non_null, alloc) = Box::into_non_null_with_allocator(x); unsafe { non_null.drop_in_place(); alloc.deallocate(non_null.cast::(), Layout::new::()); } ``` -------------------------------- ### Construct Box from NonNull Pointer Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Examples of creating a Box from a NonNull pointer using Box::from_non_null. ```rust #![feature(box_vec_non_null)] let x = Box::new(5); let non_null = Box::into_non_null(x); let x = unsafe { Box::from_non_null(non_null) }; ``` ```rust #![feature(box_vec_non_null)] use std::alloc::{alloc, Layout}; use std::ptr::NonNull; unsafe { let non_null = NonNull::new(alloc(Layout::new::()).cast::()) .expect("allocation failed"); // In general .write is required to avoid attempting to destruct // the (uninitialized) previous contents of `non_null`. non_null.write(5); let x = Box::from_non_null(non_null); } ``` -------------------------------- ### Print white color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with a white foreground color. ```rust println!("{}", value.white()); ``` -------------------------------- ### Print primary color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with the primary foreground color. ```rust println!("{}", value.primary()); ``` -------------------------------- ### Print magenta color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with a magenta foreground color. ```rust println!("{}", value.magenta()); ``` -------------------------------- ### Print fixed color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with a fixed foreground color. ```rust println!("{}", value.fixed(color)); ``` -------------------------------- ### Print green color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with a green foreground color. ```rust println!("{}", value.green()); ``` -------------------------------- ### Print red color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with a red foreground color. ```rust println!("{}", value.red()); ``` -------------------------------- ### Print yellow color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with a yellow foreground color. ```rust println!("{}", value.yellow()); ``` -------------------------------- ### Print black color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Example of printing a value with a black foreground color. ```rust println!("{}", value.black()); ``` -------------------------------- ### Define a Worker implementation Source: https://docs.rs/taquba/0.9.0/taquba/worker/trait.Worker.html Example of implementing the Worker trait for a custom struct to handle email jobs. ```rust struct EmailWorker; impl taquba::Worker for EmailWorker { async fn process(&self, job: &taquba::JobRecord) -> Result<(), taquba::WorkerError> { let to = std::str::from_utf8(&job.payload)?; send_email(to).await?; Ok(()) } } ``` -------------------------------- ### Using PermanentFailure in Worker::process Source: https://docs.rs/taquba/0.9.0/taquba/worker/struct.PermanentFailure.html Example of returning a PermanentFailure from a worker process to trigger immediate dead-lettering. ```rust async fn process(&self, job: &JobRecord) -> Result<(), WorkerError> { match http.send(...).await { Ok(_) => Ok(()), Err(e) if e.is_4xx() => Err(PermanentFailure::new(e.to_string()).into()), Err(e) => Err(e.into()), } } ``` -------------------------------- ### Leaking Box memory Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Examples of consuming a Box to return a static mutable reference. ```rust let x = Box::new(41); let static_ref: &'static mut usize = Box::leak(x); *static_ref += 1; assert_eq!(*static_ref, 42); ``` ```rust let x = vec![1, 2, 3].into_boxed_slice(); let static_ref = Box::leak(x); static_ref[0] = 4; assert_eq!(*static_ref, [4, 2, 3]); ``` -------------------------------- ### Chain fallible operations with and_then Source: https://docs.rs/taquba/0.9.0/taquba/type.Result.html Use and_then to chain operations that return a Result. The second example demonstrates handling file system metadata errors. ```rust assert_eq!(Ok(2).and_then(sq_then_to_string), Ok(4.to_string())); assert_eq!(Ok(1_000_000).and_then(sq_then_to_string), Err("overflowed")); assert_eq!(Err("not a number").and_then(sq_then_to_string), Err("not a number")); ``` ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### Initialization and Painting Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html Methods for creating new Painted instances and applying styles. ```APIDOC ## fn new(self) -> Painted ## fn paint(&self, style: S) -> Painted<&Self> ### Description new() creates a new Painted instance with default style. paint() applies a style wholesale to self, replacing any previous style. ``` -------------------------------- ### Initialize QueueConfig with overrides Source: https://docs.rs/taquba/0.9.0/taquba/struct.QueueConfig.html Demonstrates how to create a QueueConfig instance using the default values and overriding specific fields. ```rust QueueConfig { max_attempts: 10, ..QueueConfig::default() } ``` -------------------------------- ### Queue::open Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html Opens a queue with default settings using the provided object store and path. ```APIDOC ## pub async fn open(object_store: Arc, path: &str) -> Result ### Description Opens a queue with default settings. This initializes the queue state from the provided object store path. ### Parameters - **object_store** (Arc) - Required - The object store backend. - **path** (&str) - Required - The path within the object store for the queue. ``` -------------------------------- ### Queue Basic Operations Source: https://docs.rs/taquba/0.9.0/taquba/index.html Demonstrates the fundamental workflow of opening a queue, enqueuing a job, claiming it, and acknowledging completion. ```rust use std::sync::Arc; use std::time::Duration; use taquba::{Queue, object_store::memory::InMemory}; let q = Queue::open(Arc::new(InMemory::new()), "demo").await?; q.enqueue("email", b"alice@example.com".to_vec()).await?; if let Some(job) = q.claim("email", Duration::from_secs(30)).await? { // ... do the work ... q.ack(&job).await?; } q.close().await ``` -------------------------------- ### Using MockClock in Tests Source: https://docs.rs/taquba/0.9.0/taquba/struct.MockClock.html Demonstrates initializing a MockClock and advancing its time manually. ```rust use std::time::Duration; use taquba::{Clock, MockClock}; let clock = MockClock::new(1_700_000_000_000); assert_eq!(clock.now_ms(), 1_700_000_000_000); clock.advance(Duration::from_secs(60)); assert_eq!(clock.now_ms(), 1_700_000_060_000); ``` -------------------------------- ### Enable cloud storage backends via Cargo Source: https://docs.rs/taquba/0.9.0/taquba/index.html Select a specific cloud storage backend by adding the corresponding feature flag to the Taquba dependency. ```bash cargo add taquba --features aws # S3 / MinIO cargo add taquba --features gcp # Google Cloud Storage cargo add taquba --features azure # Azure Blob ``` -------------------------------- ### PolicyExt::or Source: https://docs.rs/taquba/0.9.0/taquba/struct.OpenOptions.html Creates a new Policy that returns Action::Follow if either the current policy or the provided policy returns Action::Follow. ```APIDOC ## fn or(self, other: P) -> Or ### Description Create a new `Policy` that returns `Action::Follow` if either `self` or `other` returns `Action::Follow`. ``` -------------------------------- ### Set foreground color using white() Source: https://docs.rs/taquba/0.9.0/taquba/enum.EnqueueResult.html Demonstrates setting the foreground color to white using the white method. ```rust use yansi::Paint; painted.white(); ``` -------------------------------- ### Pinning a Box Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Demonstrates the potential ambiguity when implementing From for Pin. ```rust struct Foo; // A type defined in this crate. impl From> for Pin { fn from(_: Box<()>) -> Pin { Pin::new(Foo) } } let foo = Box::new(()); let bar = Pin::from(foo); ``` -------------------------------- ### Apply Quirks Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Demonstrates applying wrapping using the generic quirk method versus the specific wrap method. ```rust use yansi::{Paint, Quirk}; painted.quirk(Quirk::Wrap); ``` ```rust use yansi::Paint; painted.wrap(); ``` -------------------------------- ### Apply Background Colors Source: https://docs.rs/taquba/0.9.0/taquba/struct.AckEffects.html Methods to set the background color using various color definitions. ```rust println!("{}", value.on_primary()); ``` ```rust println!("{}", value.on_fixed(color)); ``` ```rust println!("{}", value.on_rgb(r, g, b)); ``` ```rust println!("{}", value.on_black()); ``` ```rust println!("{}", value.on_red()); ``` ```rust println!("{}", value.on_green()); ``` ```rust println!("{}", value.on_yellow()); ``` ```rust println!("{}", value.on_blue()); ``` ```rust println!("{}", value.on_magenta()); ``` ```rust println!("{}", value.on_cyan()); ``` ```rust println!("{}", value.on_white()); ``` ```rust println!("{}", value.on_bright_black()); ``` ```rust println!("{}", value.on_bright_red()); ``` ```rust println!("{}", value.on_bright_green()); ``` ```rust println!("{}", value.on_bright_yellow()); ``` ```rust println!("{}", value.on_bright_blue()); ``` ```rust println!("{}", value.on_bright_magenta()); ``` ```rust println!("{}", value.on_bright_cyan()); ``` ```rust println!("{}", value.on_bright_white()); ``` -------------------------------- ### Apply Attributes Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Demonstrates applying bold styling using the generic attr method versus the specific bold method. ```rust use yansi::{Paint, Attribute}; painted.attr(Attribute::Bold); ``` ```rust use yansi::Paint; painted.bold(); ``` -------------------------------- ### PolicyExt::and Source: https://docs.rs/taquba/0.9.0/taquba/struct.OpenOptions.html Creates a new Policy that returns Action::Follow only if both the current policy and the provided policy return Action::Follow. ```APIDOC ## fn and(self, other: P) -> And ### Description Create a new `Policy` that returns `Action::Follow` only if `self` and `other` return `Action::Follow`. ``` -------------------------------- ### Cloning a Boxed String Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Demonstrates the usage of try_clone_from_ref_in to clone a boxed string using a specific allocator. ```rust let hello: Box = Box::try_clone_from_ref_in("hello", System)?; ``` -------------------------------- ### Construct EnqueueOptions with struct-update syntax Source: https://docs.rs/taquba/0.9.0/taquba/struct.EnqueueOptions.html Recommended way to instantiate EnqueueOptions by using the default values and overriding specific fields. ```rust use std::time::{Duration, SystemTime}; use taquba::EnqueueOptions; let opts = EnqueueOptions { run_at: Some(SystemTime::now() + Duration::from_secs(60)), ..EnqueueOptions::default() }; ``` -------------------------------- ### ack_with Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html Acknowledge successful completion and apply effects in the same transaction. ```APIDOC ## pub async fn ack_with(&self, job: &JobRecord, effects: AckEffects) -> Result> ### Description Acknowledge successful completion and apply effects in the same transaction. Either the acknowledgement and every effect land together or nothing does. ``` -------------------------------- ### Apply styling to an object Source: https://docs.rs/taquba/0.9.0/taquba/struct.QueueConfig.html Demonstrates chaining styling methods to an object based on a condition. ```rust painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY); ``` -------------------------------- ### Set foreground color using Paint Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Demonstrates setting the foreground color of a painted value using the fg method versus the white method. ```rust use yansi::{Paint, Color}; painted.fg(Color::White); ``` ```rust use yansi::Paint; painted.white(); ``` -------------------------------- ### Set foreground color using fg() Source: https://docs.rs/taquba/0.9.0/taquba/enum.EnqueueResult.html Demonstrates setting the foreground color to white using the fg method. ```rust use yansi::{Paint, Color}; painted.fg(Color::White); ``` -------------------------------- ### Enqueueing a Job with Options Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html Enqueue a job with specific priority, scheduling, and deduplication settings. ```rust use taquba::{EnqueueOptions, PRIORITY_HIGH}; q.enqueue_with("email", b"to=alice".to_vec(), EnqueueOptions { priority: Some(PRIORITY_HIGH), run_at: Some(SystemTime::now() + Duration::from_secs(300)), dedup_key: Some("welcome:user-42".to_string()), ..EnqueueOptions::default() }).await?; ``` -------------------------------- ### Construct a new box with uninitialized contents Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Creates a box with uninitialized memory. Requires manual initialization before use. ```rust let mut five = Box::::new_uninit(); // Deferred initialization: five.write(5); let five = unsafe { five.assume_init() }; assert_eq!(*five, 5) ``` -------------------------------- ### Apply Quirks Source: https://docs.rs/taquba/0.9.0/taquba/struct.EnqueueRequest.html Methods to enable specific text quirks, with preferred builder methods noted. ```rust use yansi::{Paint, Quirk}; painted.quirk(Quirk::Wrap); ``` ```rust use yansi::Paint; painted.wrap(); ``` ```rust println!("{}", value.mask()); ``` ```rust println!("{}", value.wrap()); ``` ```rust println!("{}", value.linger()); ``` ```rust println!("{}", value.clear()); ``` ```rust println!("{}", value.resetting()); ``` ```rust println!("{}", value.bright()); ``` ```rust println!("{}", value.on_bright()); ``` -------------------------------- ### Styling Methods Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html Methods to apply specific text attributes like bold, dim, italic, underline, blink, rapid_blink, invert, conceal, and strike. ```APIDOC ## fn bold(&self) -> Painted<&T> ## fn dim(&self) -> Painted<&T> ## fn italic(&self) -> Painted<&T> ## fn underline(&self) -> Painted<&T> ## fn blink(&self) -> Painted<&T> ## fn rapid_blink(&self) -> Painted<&T> ## fn invert(&self) -> Painted<&T> ## fn conceal(&self) -> Painted<&T> ## fn strike(&self) -> Painted<&T> ### Description Returns self with the corresponding attribute set. ``` -------------------------------- ### MockClock::new Source: https://docs.rs/taquba/0.9.0/taquba/struct.MockClock.html Creates a new instance of MockClock initialized to the specified millisecond value. ```APIDOC ## pub fn new(initial_ms: u64) -> Self ### Description Creates a clock whose initial value is set to the provided initial_ms. ### Parameters - **initial_ms** (u64) - Required - The initial time in milliseconds since the UNIX epoch. ``` -------------------------------- ### Construct a new box with zeroed contents Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Creates a box with uninitialized contents, pre-filled with zero bytes. ```rust let zero = Box::::new_zeroed(); let zero = unsafe { zero.assume_init() }; assert_eq!(*zero, 0) ``` -------------------------------- ### OpenOptions Struct Definition Source: https://docs.rs/taquba/0.9.0/taquba/struct.OpenOptions.html The structure definition for OpenOptions, detailing the fields used to configure queue behavior and background task intervals. ```rust pub struct OpenOptions { pub reaper_interval: Duration, pub scheduler_interval: Duration, pub default_queue_config: QueueConfig, pub queue_configs: HashMap, pub clock: Arc, pub flush_interval: Option, pub metrics_sample_interval: Option, } ``` -------------------------------- ### Calculate Product of Result Iterator Source: https://docs.rs/taquba/0.9.0/taquba/type.Result.html Demonstrates using the product method on an iterator of Results, which short-circuits on the first Err encountered. ```rust let nums = vec!["5", "10", "1", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert_eq!(total, Ok(100)); let nums = vec!["5", "10", "one", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert!(total.is_err()); ``` -------------------------------- ### Apply Bright Cyan Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Sets the background color to BrightCyan. ```rust println!("{}", value.on_bright_cyan()); ``` -------------------------------- ### Apply Dim Attribute Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Sets the dim attribute. ```rust println!("{}", value.dim()); ``` -------------------------------- ### Initialize Box with Zeroed Memory Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Constructs a new box with memory filled with zero bytes in a specific allocator. Requires the allocator_api feature. ```rust #![feature(allocator_api)] use std::alloc::System; let zero = Box::::new_zeroed_in(System); let zero = unsafe { zero.assume_init() }; assert_eq!(*zero, 0) ``` ```rust #![feature(allocator_api)] use std::alloc::System; let zero = Box::::try_new_zeroed_in(System)?; let zero = unsafe { zero.assume_init() }; assert_eq!(*zero, 0); ``` -------------------------------- ### Provide default values with unwrap_or and unwrap_or_else Source: https://docs.rs/taquba/0.9.0/taquba/type.Result.html Use unwrap_or for simple default values and unwrap_or_else for computed defaults. ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` ```rust fn count(x: &str) -> usize { x.len() } assert_eq!(Ok(2).unwrap_or_else(count), 2); assert_eq!(Err("foo").unwrap_or_else(count), 3); ``` -------------------------------- ### Apply Underline Attribute Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Sets the underline attribute. ```rust println!("{}", value.underline()); ``` -------------------------------- ### Apply Bright Green Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to BrightGreen. ```rust println!("{}", value.on_bright_green()); ``` -------------------------------- ### Clone from reference into a box Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Experimental API to allocate memory and clone a reference into it. ```rust #![feature(clone_from_ref)] let hello: Box = Box::clone_from_ref("hello"); ``` -------------------------------- ### Apply Blue Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to Blue. ```rust println!("{}", value.on_blue()); ``` -------------------------------- ### pub fn unwrap_or_default(self) -> T Source: https://docs.rs/taquba/0.9.0/taquba/type.Result.html Returns the contained Ok value or a default value if the result is Err. ```APIDOC ## pub fn unwrap_or_default(self) -> T ### Description Consumes the `self` argument then, if `Ok`, returns the contained value, otherwise if `Err`, returns the default value for that type. ### Parameters - **self** (Result) - The Result instance. ### Returns - **T** - The contained value or the default value for type T. ``` -------------------------------- ### Apply Bright Black Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to BrightBlack. ```rust println!("{}", value.on_bright_black()); ``` -------------------------------- ### Box::into_non_null_with_allocator Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Consumes the Box, returning a wrapped NonNull pointer and the allocator. ```APIDOC ## pub fn into_non_null_with_allocator(b: Box) -> (NonNull, A) ### Description Consumes the `Box`, returning a wrapped `NonNull` pointer and the allocator. The pointer will be properly aligned. The caller is responsible for the memory previously managed by the `Box`. ### Parameters - **b** (Box) - Required - The Box to consume. ``` -------------------------------- ### Cleanup via drop and Box::from_non_null Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html An alternative approach to cleanup by wrapping the pointer in a Box and dropping it. ```rust #![feature(box_vec_non_null)] let x = Box::new(String::from("Hello")); let non_null = Box::into_non_null(x); unsafe { drop(Box::from_non_null(non_null)); } ``` -------------------------------- ### Apply White Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to White. ```rust println!("{}", value.on_white()); ``` -------------------------------- ### Apply Bright Background Colors Source: https://docs.rs/taquba/0.9.0/taquba/struct.EnqueueRequest.html Methods to set the background color of a painted value to various bright colors. ```rust println!("{}", value.on_bright_green()); ``` ```rust println!("{}", value.on_bright_yellow()); ``` ```rust println!("{}", value.on_bright_blue()); ``` ```rust println!("{}", value.on_bright_magenta()); ``` ```rust println!("{}", value.on_bright_cyan()); ``` ```rust println!("{}", value.on_bright_white()); ``` -------------------------------- ### Apply Primary Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to Primary. ```rust println!("{}", value.on_primary()); ``` -------------------------------- ### Apply Bright Quirk Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Sets the bright quirk. ```rust println!("{}", value.bright()); ``` -------------------------------- ### Queue::kv_get Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html Reads a value from the user KV namespace. ```APIDOC ## pub async fn kv_get(&self, key: &[u8]) -> Result> ### Description Read a value from the user KV namespace. Keys are internally scoped under a reserved 'usr:' prefix. ``` -------------------------------- ### Apply Bright Red Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to BrightRed. ```rust println!("{}", value.on_bright_red()); ``` -------------------------------- ### Initialize Box with Uninitialized Memory Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Constructs a new box with uninitialized contents in a specific allocator. Requires the allocator_api feature. ```rust #![feature(allocator_api)] use std::alloc::System; let mut five = Box::::new_uninit_in(System); // Deferred initialization: five.write(5); let five = unsafe { five.assume_init() }; assert_eq!(*five, 5) ``` ```rust #![feature(allocator_api)] use std::alloc::System; let mut five = Box::::try_new_uninit_in(System)?; // Deferred initialization: five.write(5); let five = unsafe { five.assume_init() }; assert_eq!(*five, 5); ``` -------------------------------- ### Accessing Box contents via raw pointers Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Demonstrates the aliasing guarantees when using as_ptr and as_mut_ptr on a Box. ```rust unsafe { let mut v = Box::new(0); let ptr1 = Box::as_ptr(&v); let ptr2 = Box::as_mut_ptr(&mut v); let _val = ptr2.read(); // No write to this memory has happened yet, so `ptr1` is still valid. let _val = ptr1.read(); // However, once we do a write... ptr2.write(1); // ... `ptr1` is no longer valid. // This would be UB: let _val = ptr1.read(); } ``` -------------------------------- ### Apply Background Colors Source: https://docs.rs/taquba/0.9.0/taquba/struct.JobRecord.html Methods to set the background color of a value to a specific color. ```rust println!("{}", value.on_primary()); ``` ```rust println!("{}", value.on_fixed(color)); ``` ```rust println!("{}", value.on_rgb(r, g, b)); ``` ```rust println!("{}", value.on_black()); ``` ```rust println!("{}", value.on_red()); ``` ```rust println!("{}", value.on_green()); ``` ```rust println!("{}", value.on_yellow()); ``` ```rust println!("{}", value.on_blue()); ``` ```rust println!("{}", value.on_magenta()); ``` ```rust println!("{}", value.on_cyan()); ``` ```rust println!("{}", value.on_white()); ``` ```rust println!("{}", value.on_bright_black()); ``` -------------------------------- ### Apply Bright White Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Sets the background color to BrightWhite. ```rust println!("{}", value.on_bright_white()); ``` -------------------------------- ### Convert Result to Option Source: https://docs.rs/taquba/0.9.0/taquba/type.Result.html Use ok() to convert a Result to an Option, discarding the error, or err() to keep the error and discard the success value. ```rust let x: Result = Ok(2); assert_eq!(x.ok(), Some(2)); let x: Result = Err("Nothing here"); assert_eq!(x.ok(), None); ``` ```rust let x: Result = Ok(2); assert_eq!(x.err(), None); let x: Result = Err("Nothing here"); assert_eq!(x.err(), Some("Nothing here")); ``` -------------------------------- ### Create References from Result Source: https://docs.rs/taquba/0.9.0/taquba/type.Result.html Use as_ref() or as_mut() to obtain references to the inner values of a Result without consuming it. ```rust let x: Result = Ok(2); assert_eq!(x.as_ref(), Ok(&2)); let x: Result = Err("Error"); assert_eq!(x.as_ref(), Err(&"Error")); ``` ```rust fn mutate(r: &mut Result) { match r.as_mut() { Ok(v) => *v = 42, Err(e) => *e = 0, } } let mut x: Result = Ok(2); mutate(&mut x); assert_eq!(x.unwrap(), 42); let mut x: Result = Err(13); mutate(&mut x); assert_eq!(x.unwrap_err(), 0); ``` -------------------------------- ### Apply Bright Blue Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to BrightBlue. ```rust println!("{}", value.on_bright_blue()); ``` -------------------------------- ### Set Background Color Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Methods to set the background color, including generic and specific builder methods. ```rust use yansi::{Paint, Color}; painted.bg(Color::Red); ``` ```rust use yansi::Paint; painted.on_red(); ``` -------------------------------- ### Background Color Methods Source: https://docs.rs/taquba/0.9.0/taquba/struct.JobRecord.html Methods to set the background color of a Painted value. ```APIDOC ## fn bg(&self, value: Color) -> Painted<&T> ### Description Returns a styled value derived from `self` with the background set to `value`. ### Parameters - **value** (Color) - The background color to apply. ### Example ``` use yansi::{Paint, Color}; painted.bg(Color::Red); ``` ``` -------------------------------- ### Quirk Methods Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html Methods to enable specific quirks for terminal styling. ```APIDOC ## fn quirk(&self, value: Quirk) -> Painted<&T> ## fn mask(&self) -> Painted<&T> ## fn wrap(&self) -> Painted<&T> ## fn linger(&self) -> Painted<&T> ## fn resetting(&self) -> Painted<&T> ## fn bright(&self) -> Painted<&T> ## fn on_bright(&self) -> Painted<&T> ### Description Enables specific quirks on the Painted object. Prefer specific methods like mask() or wrap() over the generic quirk() method. ``` -------------------------------- ### Apply Background Colors Source: https://docs.rs/taquba/0.9.0/taquba/struct.EnqueueRequest.html Methods to set the background color of a painted value, including generic and specific builder methods. ```rust use yansi::{Paint, Color}; painted.bg(Color::Red); ``` ```rust use yansi::Paint; painted.on_red(); ``` ```rust println!("{}", value.on_primary()); ``` ```rust println!("{}", value.on_fixed(color)); ``` ```rust println!("{}", value.on_rgb(r, g, b)); ``` ```rust println!("{}", value.on_black()); ``` ```rust println!("{}", value.on_red()); ``` ```rust println!("{}", value.on_green()); ``` ```rust println!("{}", value.on_yellow()); ``` ```rust println!("{}", value.on_blue()); ``` ```rust println!("{}", value.on_magenta()); ``` ```rust println!("{}", value.on_cyan()); ``` ```rust println!("{}", value.on_white()); ``` ```rust println!("{}", value.on_bright_black()); ``` ```rust println!("{}", value.on_bright_red()); ``` -------------------------------- ### Chain Results with And Source: https://docs.rs/taquba/0.9.0/taquba/type.Result.html Returns the provided result if the current result is Ok, otherwise returns the Err. ```rust let x: Result = Ok(2); let y: Result<&str, &str> = Err("late error"); assert_eq!(x.and(y), Err("late error")); let x: Result = Err("early error"); let y: Result<&str, &str> = Ok("foo"); assert_eq!(x.and(y), Err("early error")); let x: Result = Err("not a 2"); let y: Result<&str, &str> = Err("late error"); assert_eq!(x.and(y), Err("not a 2")); let x: Result = Ok(2); let y: Result<&str, &str> = Ok("different result type"); assert_eq!(x.and(y), Ok("different result type")); ``` -------------------------------- ### Apply Cyan Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to Cyan. ```rust println!("{}", value.on_cyan()); ``` -------------------------------- ### Allocate memory on the heap with Box::new Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Allocates memory on the heap and places the value into it. No allocation occurs if the type is zero-sized. ```rust let five = Box::new(5); ``` -------------------------------- ### Apply Bright Foreground Colors Source: https://docs.rs/taquba/0.9.0/taquba/struct.AckEffects.html Methods to set the foreground color to various bright variants. ```rust println!("{}", value.bright_blue()); ``` ```rust println!("{}", value.bright_magenta()); ``` ```rust println!("{}", value.bright_cyan()); ``` ```rust println!("{}", value.bright_white()); ``` -------------------------------- ### Apply Wrap Quirk Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Sets the wrap quirk. ```rust println!("{}", value.wrap()); ``` -------------------------------- ### Apply Bold Attribute Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Sets the bold attribute. ```rust println!("{}", value.bold()); ``` -------------------------------- ### Queue Definition Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html The internal structure of the Queue. ```rust pub struct Queue { /* private fields */ } ``` -------------------------------- ### Convert NonNull back to Box for cleanup Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Demonstrates converting a NonNull pointer back into a Box to allow the Box destructor to handle memory cleanup. ```rust #![feature(box_vec_non_null)] let x = Box::new(String::from("Hello")); let non_null = Box::into_non_null(x); let x = unsafe { Box::from_non_null(non_null) }; ``` -------------------------------- ### Conditionally enable styling with yansi Source: https://docs.rs/taquba/0.9.0/taquba/struct.EnqueueRequest.html Use the whenever method to apply styling only when a specific Condition is met. ```rust use yansi::{Paint, Condition}; painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY); ``` -------------------------------- ### Queue::enqueue Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html Enqueues a job using the queue's configured defaults. ```APIDOC ## pub async fn enqueue(&self, queue: &str, payload: Vec) -> Result ### Description Enqueue a job using the queue’s configured defaults for max_attempts, priority, schedule, and deduplication. ### Parameters - **queue** (&str) - Required - The name of the queue. - **payload** (Vec) - Required - The job data payload. ``` -------------------------------- ### Apply styling attributes Source: https://docs.rs/taquba/0.9.0/taquba/worker/struct.PermanentFailure.html Enables specific styling attributes on a Painted object. ```rust use yansi::{Paint, Attribute}; painted.attr(Attribute::Bold); ``` -------------------------------- ### pub fn unwrap(self) -> T Source: https://docs.rs/taquba/0.9.0/taquba/type.Result.html Returns the contained Ok value, consuming the self value. Panics if the value is an Err. ```APIDOC ## pub fn unwrap(self) -> T ### Description Returns the contained `Ok` value, consuming the `self` value. Because this function may panic, its use is generally discouraged. ### Parameters - **self** (Result) - The Result instance to unwrap. ### Returns - **T** - The contained value if Ok. ### Panics Panics if the value is an `Err`, with a panic message provided by the `Err`’s value. ``` -------------------------------- ### Clone a Box Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Demonstrates creating a clone of a boxed value, resulting in a new, unique object with the same value. ```rust let x = Box::new(5); let y = x.clone(); // The value is the same assert_eq!(x, y); // But they are unique objects assert_ne!(&*x as *const i32, &*y as *const i32); ``` -------------------------------- ### Apply Bright Foreground Colors Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Methods to set the foreground color to a bright variant. ```rust println!("{}", value.bright_black()); ``` ```rust println!("{}", value.bright_red()); ``` ```rust println!("{}", value.bright_green()); ``` ```rust println!("{}", value.bright_yellow()); ``` ```rust println!("{}", value.bright_blue()); ``` ```rust println!("{}", value.bright_magenta()); ``` ```rust println!("{}", value.bright_cyan()); ``` ```rust println!("{}", value.bright_white()); ``` -------------------------------- ### Define EnqueueOptions structure Source: https://docs.rs/taquba/0.9.0/taquba/struct.EnqueueOptions.html The definition of the EnqueueOptions struct showing all available configuration fields. ```rust pub struct EnqueueOptions { pub max_attempts: Option, pub priority: Option, pub run_at: Option, pub dedup_key: Option, pub headers: HashMap, pub id_override: Option, } ``` -------------------------------- ### Enqueueing a Job with Atomic KV Writes Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html Enqueue a job and perform atomic writes to the user KV namespace. ```rust let mut kv = HashMap::new(); kv.insert(b"runs/abc".to_vec(), b"submitted".to_vec()); let outcome = q.enqueue_with_kv( "workflow-steps", b"step-0-payload".to_vec(), EnqueueOptions { dedup_key: Some("run:abc:0".to_string()), ..Default::default() }, kv, ).await?; match outcome { EnqueueResult::New(id) => println!("submitted: {id}"), EnqueueResult::AlreadyEnqueued(id) => println!("already running: {id}"), } ``` -------------------------------- ### Apply Green Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to Green. ```rust println!("{}", value.on_green()); ``` -------------------------------- ### Apply styling attributes Source: https://docs.rs/taquba/0.9.0/taquba/struct.QueueConfig.html Methods to apply styling attributes to text, with a preference for specific builder methods over the generic attr() method. ```rust use yansi::{Paint, Attribute}; painted.attr(Attribute::Bold); ``` ```rust use yansi::Paint; ``` -------------------------------- ### pub fn and_then(self, op: F) -> Result Source: https://docs.rs/taquba/0.9.0/taquba/type.Result.html Calls op if the result is Ok, otherwise returns the Err value of self. ```APIDOC ## pub fn and_then(self, op: F) -> Result ### Description Calls `op` if the result is `Ok`, otherwise returns the `Err` value of `self`. This function can be used for control flow based on `Result` values. ### Parameters - **op** (F) - A function that takes the value T and returns a new Result. ### Returns - **Result** - The result of the operation or the original error. ``` -------------------------------- ### Fallible zeroed heap allocation Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Experimental API for creating a box with zeroed contents that returns an error on allocation failure. ```rust #![feature(allocator_api)] let zero = Box::::try_new_zeroed()?; let zero = unsafe { zero.assume_init() }; assert_eq!(*zero, 0); ``` -------------------------------- ### Apply Bright Magenta Background Source: https://docs.rs/taquba/0.9.0/taquba/struct.EnqueueOptions.html Sets the background color to BrightMagenta. ```rust println!("{}", value.on_bright_magenta()); ``` -------------------------------- ### Apply Black Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to Black. ```rust println!("{}", value.on_black()); ``` -------------------------------- ### promote_scheduled_now Source: https://docs.rs/taquba/0.9.0/taquba/struct.Queue.html Trigger an immediate scheduled-job promotion sweep. ```APIDOC ## pub async fn promote_scheduled_now(&self) -> Result<()> ### Description Triggers an immediate scheduled-job promotion sweep, primarily useful for testing purposes. ``` -------------------------------- ### Apply bright colors Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Applies bright foreground colors to a value. ```rust println!("{}", value.bright_black()); ``` ```rust println!("{}", value.bright_red()); ``` ```rust println!("{}", value.bright_green()); ``` ```rust println!("{}", value.bright_yellow()); ``` ```rust println!("{}", value.bright_blue()); ``` -------------------------------- ### Apply Fixed Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to a fixed 8-bit color. ```rust println!("{}", value.on_fixed(color)); ``` -------------------------------- ### Box::into_raw_with_allocator Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Consumes the Box, returning a wrapped raw pointer and the allocator. The caller is responsible for the memory previously managed by the Box. ```APIDOC ## pub fn into_raw_with_allocator(b: Box) -> (*mut T, A) ### Description Consumes the `Box`, returning a wrapped raw pointer and the allocator. The pointer will be properly aligned and non-null. After calling this function, the caller is responsible for the memory previously managed by the `Box`. ### Parameters - **b** (Box) - Required - The Box to consume. ``` -------------------------------- ### Clone Reference into Box Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Allocates memory in the given allocator and clones the source reference into it. Requires allocator_api and clone_from_ref features. ```rust #![feature(clone_from_ref)] #![feature(allocator_api)] use std::alloc::System; let hello: Box = Box::clone_from_ref_in("hello", System); ``` -------------------------------- ### Apply Italic Attribute Source: https://docs.rs/taquba/0.9.0/taquba/enum.CancelOutcome.html Sets the italic attribute. ```rust println!("{}", value.italic()); ``` -------------------------------- ### Apply Attributes Source: https://docs.rs/taquba/0.9.0/taquba/struct.EnqueueRequest.html Methods to apply text attributes like bold, italic, or underline. ```rust use yansi::{Paint, Attribute}; painted.attr(Attribute::Bold); ``` ```rust use yansi::Paint; painted.bold(); ``` ```rust println!("{}", value.bold()); ``` ```rust println!("{}", value.dim()); ``` ```rust println!("{}", value.italic()); ``` ```rust println!("{}", value.underline()); ``` ```rust println!("{}", value.blink()); ``` ```rust println!("{}", value.rapid_blink()); ``` ```rust println!("{}", value.invert()); ``` ```rust println!("{}", value.conceal()); ``` ```rust println!("{}", value.strike()); ``` -------------------------------- ### Fallible clone from reference into a box Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Experimental API to allocate memory and clone a reference, returning an error if allocation fails. ```rust #![feature(clone_from_ref)] #![feature(allocator_api)] let hello: Box = Box::try_clone_from_ref("hello")?; ``` -------------------------------- ### Apply Red Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to Red. ```rust println!("{}", value.on_red()); ``` -------------------------------- ### Apply RGB Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color using RGB values. ```rust println!("{}", value.on_rgb(r, g, b)); ``` -------------------------------- ### Manual memory cleanup Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Shows how to manually drop the value and deallocate the memory associated with a NonNull pointer. ```rust #![feature(box_vec_non_null)] use std::alloc::{dealloc, Layout}; let x = Box::new(String::from("Hello")); let non_null = Box::into_non_null(x); unsafe { non_null.drop_in_place(); dealloc(non_null.as_ptr().cast::(), Layout::new::()); } ``` -------------------------------- ### Fallible uninitialized heap allocation Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Experimental API for creating a box with uninitialized contents that returns an error on allocation failure. ```rust #![feature(allocator_api)] let mut five = Box::::try_new_uninit()?; // Deferred initialization: five.write(5); let five = unsafe { five.assume_init() }; assert_eq!(*five, 5); ``` -------------------------------- ### Convert Cow to Boxed Error Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Demonstrates converting a Cow string error into a boxed dyn Error. ```rust let a_cow_str_error = Cow::from("a str error"); let a_boxed_error = Box::::from(a_cow_str_error); assert!(size_of::>() == size_of_val(&a_boxed_error)) ``` ```rust use std::error::Error; use std::borrow::Cow; let a_cow_str_error = Cow::from("a str error"); let a_boxed_error = Box::::from(a_cow_str_error); assert!( size_of::>() == size_of_val(&a_boxed_error)) ``` -------------------------------- ### Into Ok Value Source: https://docs.rs/taquba/0.9.0/taquba/type.Result.html Extracts the Ok value without risk of panicking, useful for infallible Result types. ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` -------------------------------- ### MockClock::now_ms Source: https://docs.rs/taquba/0.9.0/taquba/struct.MockClock.html Returns the current time as milliseconds since the UNIX epoch. ```APIDOC ## fn now_ms(&self) -> u64 ### Description Returns the current time as milliseconds since the UNIX epoch. ### Returns - **u64** - The current time in milliseconds. ``` -------------------------------- ### Apply background color Source: https://docs.rs/taquba/0.9.0/taquba/struct.QueueConfig.html Sets the background color of a styled value. Prefer color-specific builder methods for brevity. ```rust use yansi::{Paint, Color}; painted.bg(Color::Red); ``` -------------------------------- ### Convert Cow to Boxed Error Source: https://docs.rs/taquba/0.9.0/taquba/worker/type.WorkerError.html Demonstrates converting a Cow string into a boxed dynamic error. ```rust use std::error::Error; use std::borrow::Cow; ``` -------------------------------- ### Apply Magenta Background Source: https://docs.rs/taquba/0.9.0/taquba/enum.WaitOutcome.html Sets the background color to Magenta. ```rust println!("{}", value.on_magenta()); ```