### Basic Example Usage in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md A minimal example demonstrating the core functionality of VelvetIO, including asking for a string, a parsed number, and a confirmation. It shows how to use the `ask!` and `confirm!` macros together. ```rust use velvetio::prelude::*; let name = ask!("Your name"); let age = ask!("Age" => u32); if confirm!("Continue?") { println!("Hello {}, age {}", name, age); } ``` -------------------------------- ### Rust: User Registration Form Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Provides an example of a user registration form, including validation for username and email, and optional input for age. ```rust let username = ask!( "Username", validate: and(min_length(3), max_length(20)), error: "Username must be 3-20 characters" ); let email = ask!( "Email", validate: |s: &String| s.contains('@'), error: "Please enter a valid email" ); let age: Option = ask!("Age (optional)" => Option); ``` -------------------------------- ### Installation: Adding VelvetIO to Rust Project Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Provides the TOML snippet required to add VelvetIO as a dependency to a Rust project's `Cargo.toml` file. Specifies the version to be used. ```toml [dependencies] velvetio = "0.1" ``` -------------------------------- ### Rust: Custom Type Parsing with FromStr and quick_parse! Source: https://context7.com/hunter-arton/velvetio/llms.txt Demonstrates how to enable parsing of custom types for use with Velvetio's `ask!` macro by implementing the `std::str::FromStr` trait and using the `quick_parse!` macro. It shows examples with `UserId` and `Email` structs. ```rust use velvetio::prelude::*; use std::str::FromStr; #[derive(Debug)] struct UserId(u32); impl FromStr for UserId { type Err = (); fn from_str(s: &str) -> Result { s.parse::() .map(UserId) .map_err(|_| ()) } } // Add parsing support quick_parse!(UserId); #[derive(Debug)] struct Email(String); impl FromStr for Email { type Err = (); fn from_str(s: &str) -> Result { if s.contains('@') && s.contains('.') { Ok(Email(s.to_string())) } else { Err(()) } } } quick_parse!(Email); fn main() { // Now use custom types with ask! let user_id = ask!("User ID" => UserId); let email = ask!("Email" => Email); println!("User: {:?}", user_id); println!("Email: {:?}", email); // Custom types work with all features let optional_id: Option = ask!("Optional ID" => Option); let ids: Vec = ask!("Multiple IDs" => Vec); println!("IDs: {:?}", ids); } ``` -------------------------------- ### Quick Form Macro in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Provides a concise macro `quick_form!` for creating simple forms where only field names and labels are needed. This is a shorthand for common form definitions without requiring explicit type or validation setup. ```rust let info = quick_form! { "name" => "Your name", "email" => "Email address", "company" => "Company" }; ``` -------------------------------- ### Rust: Utilizing Built-in Validators Source: https://context7.com/hunter-arton/velvetio/llms.txt Showcases the use of pre-built validation functions provided by Velvetio for common input patterns. Examples include checking for non-empty strings, minimum/maximum lengths, positive numbers, and specific numeric ranges. ```rust use velvetio::prelude::*; fn main() { // String validators let name = ask!( "Name", validate: not_empty, error: "Name cannot be empty" ); let username = ask!( "Username", validate: min_length(3), error: "Username must be at least 3 characters" ); let title = ask!( "Title", validate: max_length(50), error: "Title cannot exceed 50 characters" ); // Number validators let count = ask!( "Count" => u32, validate: is_positive, error: "Must be greater than zero" ); let port = ask!( "Port" => u16, validate: in_range(1024, 65535), error: "Port must be between 1024 and 65535" ); // Combining validators with and() let password = ask!( "Password", validate: and(min_length(8), not_empty), error: "Password must be at least 8 characters" ); // Combining with or() let code = ask!( "Code", validate: or( |s: &String| s.len() == 4, |s: &String| s.len() == 6 ), error: "Code must be 4 or 6 characters" ); println!("Valid inputs: name={}, username={}, port={}", name, username, port); } ``` -------------------------------- ### Rust: Complex Validation Patterns Source: https://context7.com/hunter-arton/velvetio/llms.txt Illustrates how to combine multiple validators and custom logic for sophisticated input validation in Rust using Velvetio. Examples include email format validation, complex username rules, password strength checks, port range validation, and URL format checks. ```rust use velvetio::prelude::*; fn main() { // Email validation let email = ask!( "Email", validate: |s: &String| s.contains('@') && s.contains('.') && s.len() > 5, error: "Please enter a valid email address" ); // Complex username rules let username = ask!( "Username", validate: and( min_length(3), |s: &String| s.chars().all(|c| c.is_alphanumeric() || c == '_') ), error: "Username: 3+ chars, alphanumeric and underscores only" ); // Password strength let password = ask!( "Password", validate: and( min_length(8), |s: &String| s.chars().any(|c| c.is_uppercase()) && s.chars().any(|c| c.is_numeric()) ), error: "Password needs 8+ chars, 1 uppercase, 1 number" ); // Port range with multiple conditions let port = ask!( "Port" => u16, validate: and( is_positive, in_range(1024, 65535) ), error: "Port must be between 1024 and 65535" ); // URL validation let url = ask!( "Repository URL", validate: |s: &String| s.starts_with("https://") && s.len() > 10, error: "URL must start with https://" ); println!("Valid credentials: {} / {}", username, email); println!("Server port: {}", port); println!("Repository: {}", url); } ``` -------------------------------- ### Rust: Building a Configuration Wizard Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Demonstrates a common pattern for creating a configuration wizard using `form()` to collect various types of input, including text, choices, multi-choices, and booleans. ```rust let config = form() .text("name", "Project name") .choice("framework", "Framework", &["Axum", "Warp", "Rocket"]) .multi_choice("features", "Features", &["Auth", "DB", "Cache"]) .boolean("docker", "Use Docker?") .collect(); ``` -------------------------------- ### Conditional Workflow Wizard with Rust and VelvetIO Source: https://context7.com/hunter-arton/velvetio/llms.txt Builds an interactive server configuration wizard using VelvetIO. It demonstrates conditional logic based on user selections for server type, gathers specific configurations, and optionally collects SSL details. Dependencies include the `velvetio` crate. ```rust use velvetio::prelude::*; fn main() { println!("Server Configuration Wizard\n"); let server_type = choose!("Server type", ["Web", "API", "Database", "Cache"]); // Base configuration let host = ask!("Host", default: "0.0.0.0".to_string()); let port = ask!("Port" => u16, default: 8080); // Conditional configuration based on server type let specific_config = match server_type { "Web" => { let static_dir = ask!("Static files directory"); let use_compression = confirm!("Enable gzip compression?"); format!("Static: {}, Gzip: {}", static_dir, use_compression) }, "API" => { let api_version = ask!("API version"); let rate_limit = ask!("Rate limit (req/min)" => u32); format!("API v{}, Rate limit: {}/min", api_version, rate_limit) }, "Database" => { let max_connections = ask!("Max connections" => u32, default: 100); let pool_size = ask!("Connection pool size" => u32, default: 10); format!("Max: {}, Pool: {}", max_connections, pool_size) }, _ => String::from("Default configuration") }; // Optional SSL configuration let ssl_config = if confirm!("Enable SSL?") { Some(form() .text("cert_path", "Certificate path") .text("key_path", "Private key path") .optional("ca_cert", "CA certificate (optional)") .collect()) } else { None }; // Summary println!("\nConfiguration Complete:"); println!("Type: {}", server_type); println!("Address: {}:{}", host, port); println!("Config: {}", specific_config); if let Some(ssl) = ssl_config { println!("SSL Certificate: {}", ssl.get("cert_path").unwrap()); } } ``` -------------------------------- ### Rust: Server Configuration Prompts Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Shows a pattern for gathering server configuration details, including host, port, worker threads, and conditional prompts for SSL certificate paths. ```rust let host = ask!("Host", default: "0.0.0.0".to_string()); let port = ask!("Port" => u16, default: 8080); let workers = ask!("Worker threads" => usize, default: 4); let ssl = confirm!("Enable SSL?"); if ssl { let cert_path = ask!("Certificate path"); let key_path = ask!("Private key path"); } ``` -------------------------------- ### Basic Input Collection in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Demonstrates how to ask for various basic data types like strings, unsigned integers, floating-point numbers, and booleans. The `ask!` macro handles the input and parsing, inferring types where possible or explicitly specified. ```rust use velvetio::prelude::*; // Strings (most common) let name = ask!("Name"); // Numbers let port = ask!("Port" => u16); let price = ask!("Price" => f64); // Booleans (accepts y/n, yes/no, true/false, 1/0) let enabled = ask!("Enable feature?" => bool); ``` -------------------------------- ### Input with Defaults and Fallbacks in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Shows how to provide default values for input prompts and how to specify fallback values if initial parsing fails. This enhances user experience by allowing quick confirmation or recovery from errors. Defaults are used when the user simply presses Enter. ```rust // Hit enter to use the default let host = ask!("Host", default: "localhost".to_string()); let port = ask!("Port" => u16, default: 8080); // Try once, fall back if parsing fails let timeout = ask!("Timeout" => u32, or: 30); ``` -------------------------------- ### Simplified Form Macro for Key-Value Data (Rust) Source: https://context7.com/hunter-arton/velvetio/llms.txt Utilize a simplified macro syntax for quickly collecting basic key-value user inputs. All collected values are stored as strings in a HashMap. ```rust use velvetio::prelude::*; fn main() { let user_info = quick_form! { "name" => "Full name", "email" => "Email address", "company" => "Company name", "phone" => "Phone number" }; // Returns HashMap println!("User: {}", user_info.get("name").unwrap()); println!("Email: {}", user_info.get("email").unwrap()); // Iterate over collected data for (key, value) in &user_info { println!("{}: {}", key, value); } // All values are strings - parse if needed println!("Collected {} fields", user_info.len()); } ``` -------------------------------- ### Rust: Manual Error Handling with try_ask! Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Shows how to use `try_ask!` for explicit error handling of user input, allowing for custom error management instead of automatic retries. ```rust match try_ask!("Age" => u32) { Ok(age) => println!("Age: {}", age), Err(e) => { eprintln!("Failed to get age: {}", e); std::process::exit(1); } } ``` -------------------------------- ### Choice Selection (Single and Multi) in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Demonstrates how to present users with a list of options to choose from. `choose!` is for single selections, while `multi_select!` allows users to pick multiple items, typically by entering comma-separated numbers or keywords. ```rust // Pick one let os = choose!("Operating System", [ "Linux", "macOS", "Windows" ]); // Pick multiple (comma-separated: 1,3,5 or "all" or "none") let features = multi_select!("Features to enable", [ "Authentication", "Logging", "Caching", "Metrics" ]); ``` -------------------------------- ### Optional Input Parsing in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Explains how to handle optional inputs using `Option`. VelvetIO automatically maps specific keywords like 'none', 'null', or an empty input to `None`, while other valid inputs are parsed into `Some(value)`. ```rust let backup_email: Option = ask!("Backup email" => Option); // Empty input, "none", "null", "-", or "skip" becomes None // Anything else gets parsed as Some(value) ``` -------------------------------- ### Rust: Integrating rpassword for Secure Password Input Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Illustrates how to combine VelvetIO for general input with the `rpassword` crate for secure, hidden password entry, as VelvetIO does not provide this functionality directly. ```rust use velvetio::prelude::*; let username = ask!("Username"); let password = rpassword::prompt_password("Password: ").unwrap(); ``` -------------------------------- ### Rust: Custom Input Validators Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Demonstrates how to implement custom validation logic for user inputs like email, port ranges, and usernames using closures and predefined validation functions. ```rust // Email validation let email = ask!( "Email", validate: |s: &String| s.contains('@') && s.contains('.'), error: "Please enter a valid email" ); // Port range let port = ask!( "Port" => u16, validate: in_range(1024, 65535), error: "Port must be between 1024 and 65535" ); // Complex validation let username = ask!( "Username", validate: and( min_length(3), |s: &String| s.chars().all(|c| c.is_alphanumeric() || c == '_') ), error: "Username must be 3+ chars, alphanumeric and underscores only" ); ``` -------------------------------- ### Rust: Explicit Error Handling with try_ask! Source: https://context7.com/hunter-arton/velvetio/llms.txt Demonstrates how to handle input errors explicitly using `try_ask!` instead of relying on automatic retries. It shows basic usage for different types (u32, String) and how to implement fallback strategies with `unwrap_or_else`. ```rust use velvetio::prelude::*; fn main() { // Try once, return Result match try_ask!("Enter age" => u32) { Ok(age) => println!("Age: {}", age), Err(e) => { eprintln!("Error: {}", e); std::process::exit(1); } } // String input let result = try_ask!("Username"); match result { Ok(username) => println!("Username: {}", username), Err(err) => eprintln!("Failed: {}", err) } // Use with fallback strategy let port = try_ask!("Port" => u16).unwrap_or_else(|_| { eprintln!("Using default port"); 8080 }); println!("Port: {}", port); } ``` -------------------------------- ### Confirmation Prompts in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Shows how to ask simple yes/no questions to the user using the `confirm!` macro. It returns a boolean value based on the user's input (e.g., 'y' for yes, 'n' for no). ```rust let proceed = confirm!("Delete all files?"); let save_config = confirm!("Save configuration?"); ``` -------------------------------- ### Basic String Input in Rust with VelvetIO Source: https://context7.com/hunter-arton/velvetio/llms.txt Collects basic string input from the user. Supports optional validation using a closure and provides default values. Handles potential errors during input by retrying. It's useful for collecting free-form text like names or general responses. ```rust use velvetio::prelude::*; fn main() { // Basic string input let name = ask!("Enter your name"); // With validation let email = ask!( "Email address", validate: |e: &String| e.contains('@') && e.contains('.'), error: "Must be a valid email address" ); // With default value let host = ask!("Host", default: "localhost".to_string()); println!("Hello {}, your email is {}", name, email); println!("Connecting to {}", host); } ``` -------------------------------- ### Custom Type Parsing Registration in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Shows how to enable VelvetIO to parse custom types by implementing the `std::str::FromStr` trait and using the `quick_parse!` macro. This allows users to define their own structures or enums for input. ```rust #[derive(Debug)] struct UserId(u32); impl std::str::FromStr for UserId { type Err = (); fn from_str(s: &str) -> Result { s.parse::().map(UserId).map_err(|_| ()) } } // Add parsing support use velvetio::quick_parse; quick_parse!(UserId); // Now you can use it let user_id = ask!("User ID" => UserId); ``` -------------------------------- ### Parse Optional Inputs from User (Rust) Source: https://context7.com/hunter-arton/velvetio/llms.txt Handle user inputs that may be empty or explicitly marked as none. Accepts standard 'none' keywords and returns an Option type. ```rust use velvetio::prelude::*; fn main() { // Optional string - empty/"none"/"null"/"-"/"skip" becomes None let backup_email: Option = ask!("Backup email (optional)" => Option); // Optional number let middle_initial: Option = ask!("Middle initial (optional)" => Option); let budget: Option = ask!("Budget limit (optional)" => Option); // Use with validation let company: Option = ask!("Company name (optional)" => Option); match backup_email { Some(email) => println!("Backup email: {}", email), None => println!("No backup email provided") } if let Some(init) = middle_initial { println!("Middle initial: {}", init); } let final_budget = budget.unwrap_or(0.0); println!("Budget: ${:.2}", final_budget); } ``` -------------------------------- ### Input Validation in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Illustrates how to validate user input using custom closure functions or predefined validators. VelvetIO allows specifying validation logic directly within the `ask!` macro, along with custom error messages for failed validations. ```rust // Simple validation let email = ask!("Email", validate: |s| s.contains('@')); // With custom error message let username = ask!( "Username", validate: |s: &String| s.len() >= 3, error: "Username must be at least 3 characters" ); // Built-in validators use velvetio::validators::{and, min_length, not_empty}; let password = ask!( "Password", validate: and(min_length(8), not_empty), error: "Password must be at least 8 characters" ); ``` -------------------------------- ### Form Builder for Multiple Inputs in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Illustrates the `form()` builder for collecting multiple related inputs in a structured way. It allows defining fields with labels, types, validation, and optionality. The collected data is stored in a map-like structure. ```rust use velvetio::prelude::*; use velvetio::validators::{and, min_length, not_empty}; let config = form() .text("app_name", "Application name") .number("port", "Port number") .boolean("debug", "Enable debug mode?") .choice("env", "Environment", &["dev", "staging", "prod"]) .multi_choice("features", "Features", &["auth", "db", "cache"]) .optional("description", "Description (optional)") .validated_text( "email", "Admin email", |email| email.contains('@'), "Must be a valid email" ) .collect(); // Access values let app_name = config.get("app_name").unwrap(); let port: u16 = config.get("port").unwrap().parse().unwrap(); ``` -------------------------------- ### Build Forms with Chainable Methods (Rust) Source: https://context7.com/hunter-arton/velvetio/llms.txt Construct complex input forms using a chainable builder pattern. Supports various input types including text, numbers, booleans, choices, multi-choices, optional fields, and validated text inputs. ```rust use velvetio::prelude::*; fn main() { let config = form() .text("app_name", "Application name") .number("port", "Port number") .boolean("debug", "Enable debug mode?") .choice("env", "Environment", &["dev", "staging", "prod"]) .multi_choice("features", "Features", &["auth", "db", "cache", "logging"]) .optional("description", "Description (optional)") .validated_text( "email", "Admin email", |email| email.contains('@'), "Must be a valid email" ) .collect(); // Access values from HashMap let app_name = config.get("app_name").unwrap(); let port = config.get("port").unwrap(); let debug_mode = config.get("debug").unwrap(); let features = config.get("features").unwrap(); println!("App: {} on port {}", app_name, port); println!("Debug: {}", debug_mode); println!("Features: {}", features); // Parse stored values let port_num: u16 = port.parse().unwrap(); println!("Listening on 0.0.0.0:{}", port_num); } ``` -------------------------------- ### Multiple Choice Selection in Rust with VelvetIO Source: https://context7.com/hunter-arton/velvetio/llms.txt Allows users to select multiple items from a presented list using comma-separated indices. Supports special inputs like 'all' or 'none'. Returns a `Vec` containing the selected options. ```rust use velvetio::prelude::*; fn main() { // Select multiple features let features = multi_select!("Enable features", [ "Authentication", "Logging", "Caching", "Metrics", "Rate Limiting" ]); // Languages selection let languages = multi_select!( "Programming languages", ["Rust", "Python", "JavaScript", "Go", "TypeScript"] ); if features.is_empty() { println!("No features selected"); } else { println!("Enabled features: {}", features.join(", ")); } println!("You use: {}", languages.join(", ")); // User can input: "1,3,5" or "all" or "none" } ``` -------------------------------- ### Single Choice Selection in Rust with VelvetIO Source: https://context7.com/hunter-arton/velvetio/llms.txt Presents a numbered list of options to the user and collects a single selection. Supports inline arrays, `Vec`, and string slices. The selected item is returned as a String. ```rust use velvetio::prelude::*; fn main() { // Using macro with inline array let os = choose!("Select your operating system", [ "Linux", "macOS", "Windows", "BSD" ]); // Using variable let frameworks = vec!["Axum", "Actix-Web", "Warp", "Rocket"]; let framework = choose!("Web framework", frameworks); // With string slices let database = choose!( "Database type", &["PostgreSQL", "MySQL", "SQLite", "MongoDB"] ); println!("Selected: {} on {}", framework, os); println!("Database: {}", database); } ``` -------------------------------- ### Boolean Input (Yes/No) in Rust with VelvetIO Source: https://context7.com/hunter-arton/velvetio/llms.txt Handles boolean input, accepting various formats like 'yes'/'no', 'y'/'n', 'true'/'false', and '1'/'0'. Simplifies confirmation prompts and boolean flag collection. Returns a standard `bool` type. ```rust use velvetio::prelude::*; fn main() { // Simple confirmation let proceed = confirm!("Continue with installation?"); // Boolean parsing with ask! macro let debug_mode = ask!("Enable debug mode?" => bool); let use_ssl = ask!("Use SSL?" => bool); if proceed { println!("Starting installation..."); if debug_mode { println!("Debug logging enabled"); } if use_ssl { println!("SSL certificates required"); } } else { println!("Installation cancelled"); } } ``` -------------------------------- ### Parse Vectors from User Input (Rust) Source: https://context7.com/hunter-arton/velvetio/llms.txt Collect comma-separated, space-separated, or pipe-separated values into vectors of strings, numbers, or floats. Handles empty inputs by returning an empty vector. ```rust use velvetio::prelude::*; fn main() { // String vector - accepts "rust,python,go" or "rust python go" let tags: Vec = ask!("Project tags" => Vec); // Number vector - accepts "1,2,3" or "1 2 3" or "1|2|3" let numbers: Vec = ask!("Enter numbers" => Vec); // Float vector let prices: Vec = ask!("Product prices" => Vec); println!("Tags: {:?}", tags); println!("Numbers: {:?}", numbers); println!("Sum: {}", numbers.iter().sum::()); println!("Prices: ${:?}", prices); // Empty input returns empty vector } ``` -------------------------------- ### VelvetIO Built-in Validators in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Lists and explains the commonly used built-in validators provided by VelvetIO for strings, numbers, and combining multiple validators. These can be used directly within the `validate` closure of the `ask!` macro. ```rust // String validators not_empty // String is not empty min_length(n) // At least n characters max_length(n) // At most n characters // Number validators is_positive // Greater than zero in_range(min, max) // Between min and max (inclusive) // Combining validators and(v1, v2) // Both must pass or(v1, v2) // Either can pass ``` -------------------------------- ### Advanced Type Parsing (Collections and Tuples) in Rust Source: https://github.com/hunter-arton/velvetio/blob/main/README.md Demonstrates VelvetIO's ability to automatically parse complex types like `Vec` and tuples. It handles various separators for collections and different delimiters for tuples, making it easy to input structured data. ```rust // Vec - detects separators automatically let numbers: Vec = ask!("Numbers" => Vec); // Input: "1,2,3" or "1 2 3" or "1;2;3" or "1|2|3" let tags: Vec = ask!("Tags" => Vec); // Input: "rust,cli,tool" // Pairs let coords: (f64, f64) = ask!("Coordinates (lat,lng)" => (f64, f64)); // Input: "40.7,-74.0" or "40.7 -74.0" // Triples let rgb: (u8, u8, u8) = ask!("RGB color" => (u8, u8, u8)); // Input: "255,128,0" ``` -------------------------------- ### Parse Tuples (Pairs/Triples) from User Input (Rust) Source: https://context7.com/hunter-arton/velvetio/llms.txt Collect coordinate pairs or triples with automatic separator detection for numerical or string types. Supports mixed types within tuples. ```rust use velvetio::prelude::*; fn main() { // Coordinate pair - accepts "40.7,-74.0" or "40.7 -74.0" let location: (f64, f64) = ask!("Coordinates (lat,lng)" => (f64, f64)); // Integer pair let dimensions: (u32, u32) = ask!("Image size (width,height)" => (u32, u32)); // RGB color triple - accepts "255,128,0" or "255 128 0" let color: (u8, u8, u8) = ask!("RGB color" => (u8, u8, u8)); // Mixed types let server_info: (String, u16) = ask!("Server (host,port)" => (String, u16)); println!("Location: {:?}", location); println!("Dimensions: {}x{}", dimensions.0, dimensions.1); println!("RGB: ({}, {}, {})", color.0, color.1, color.2); println!("Server: {}:{}", server_info.0, server_info.1); } ``` -------------------------------- ### Type-Safe Numeric Input in Rust with VelvetIO Source: https://context7.com/hunter-arton/velvetio/llms.txt Parses user input directly into various numeric types (integers and floats) with automatic validation. Supports default values and fallback values on error. Includes range validation for bounded numeric inputs. Ensures type safety at compile time. ```rust use velvetio::prelude::*; fn main() { // Integer input let age = ask!("Your age" => u32); let temperature = ask!("Temperature" => i32); // Floating point let price = ask!("Enter price" => f64); let pi_approx = ask!("Pi approximation" => f32); // With default value let port = ask!("Server port" => u16, default: 8080); // With fallback on error let timeout = ask!("Timeout (seconds)" => u32, or: 30); // With range validation let percent = ask!( "Percentage" => u8, validate: in_range(0, 100), error: "Must be between 0 and 100" ); println!("Age: {}, Port: {}, Price: ${:.2}", age, port, price); println!("Valid percentage: {}%", percent); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.