### Get Host and Port Source: https://docs.rs/warp10/2.0.0/warp10/struct.Client.html Retrieves the host and an optional port string from the client's configuration. ```rust pub fn host_and_maybe_port(&self) -> String ``` -------------------------------- ### Getting a Reference to the Ok Value Source: https://docs.rs/warp10/2.0.0/warp10/type.Result.html The `as_ref()` method converts a `&Result` to `Result<&T, &E>`, providing immutable references to the contained values without consuming the original Result. ```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")); ``` -------------------------------- ### Get Writer Source: https://docs.rs/warp10/2.0.0/warp10/struct.Client.html Obtains a Writer instance for sending data to Warp10, requiring an authentication token. ```rust pub fn get_writer(&self, token: String) -> Writer<'_> ``` -------------------------------- ### Iterating Over Ok Value in Rust Result Source: https://docs.rs/warp10/2.0.0/warp10/type.Result.html Illustrates how to get an iterator that yields the Ok value if present, using iter(). ```rust let x: Result = Ok(7); assert_eq!(x.iter().next(), Some(&7)); let x: Result = Err("nothing!"); assert_eq!(x.iter().next(), None); ``` -------------------------------- ### Error Description Method (Deprecated) Source: https://docs.rs/warp10/2.0.0/warp10/enum.Error.html Deprecated method for getting a string description of the error. It is recommended to use the Display implementation or `to_string()` instead. ```rust fn description(&self) -> &str ``` -------------------------------- ### New Client Instance Source: https://docs.rs/warp10/2.0.0/warp10/struct.Client.html Creates a new Client instance with the specified URI. Returns a Result containing the Client or an error. ```rust pub fn new(uri: &str) -> Result ``` -------------------------------- ### Basic Result Usage Source: https://docs.rs/warp10/2.0.0/warp10/type.Result.html Demonstrates the basic usage of Result with Ok and assert_eq. ```rust let x: Result = Ok(2); assert_eq!(x.unwrap(), 2); ``` -------------------------------- ### Client::new Source: https://docs.rs/warp10/2.0.0/warp10/struct.Client.html Creates a new Client instance with the specified URI. Returns a Result containing the Client or an error. ```APIDOC ## Client::new ### Description Creates a new Client instance with the specified URI. ### Method `new` ### Parameters #### Path Parameters - **uri** (string) - Required - The URI for the client connection. ### Returns - Result - A Result containing the new Client or an error. ``` -------------------------------- ### Handling File Metadata with `Result` Source: https://docs.rs/warp10/2.0.0/warp10/type.Result.html Shows how to use `Result` and its methods like `and_then` to safely access file metadata, handling potential errors like 'NotFound'. ```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); ``` -------------------------------- ### Getting a Mutable Reference to the Value Source: https://docs.rs/warp10/2.0.0/warp10/type.Result.html The `as_mut()` method converts a `&mut Result` to `Result<&mut T, &mut E>`, allowing mutable access to the contained values. ```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); ``` -------------------------------- ### Generic CloneToUninit Implementation (Nightly) Source: https://docs.rs/warp10/2.0.0/warp10/struct.Label.html An experimental nightly-only API for performing copy-assignment from self to uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Writer::new Source: https://docs.rs/warp10/2.0.0/warp10/struct.Writer.html Creates a new Writer instance. This is the entry point for interacting with the Writer functionality. ```APIDOC ## Writer::new ### Description Creates a new Writer instance, used for posting data. ### Signature `pub fn new(client: &'a Client, token: Token<'a>) -> Self` ### Parameters * **client** (`&'a Client`) - A reference to the Client object. * **token** (`Token<'a>`) - The authentication token. ``` -------------------------------- ### Client::host_and_maybe_port Source: https://docs.rs/warp10/2.0.0/warp10/struct.Client.html Returns the host and an optional port as a String. ```APIDOC ## Client::host_and_maybe_port ### Description Returns the host and an optional port as a String. ### Method `host_and_maybe_port` ### Returns - String - The host and optional port. ``` -------------------------------- ### Label Constructor Source: https://docs.rs/warp10/2.0.0/warp10/struct.Label.html Creates a new Label with a given name and value. This is the primary way to instantiate a Label. ```rust pub fn new(name: &str, value: &str) -> Label ``` -------------------------------- ### Recommended expect() Message Style Source: https://docs.rs/warp10/2.0.0/warp10/type.Result.html Provides guidance on crafting effective error messages for the expect() method, focusing on the expected condition. ```rust let path = std::env::var("IMPORTANT_PATH") .expect("env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`"); ``` -------------------------------- ### Writer Constructor Source: https://docs.rs/warp10/2.0.0/warp10/struct.Writer.html Creates a new instance of the Writer. Requires a reference to a Client and a Token. ```rust pub fn new(client: &'a Client, token: Token<'a>) -> Self ``` -------------------------------- ### Error Provide Method (Nightly) Source: https://docs.rs/warp10/2.0.0/warp10/enum.Error.html A nightly-only experimental API for providing type-based access to context intended for error reports. ```rust fn provide<'a>(&'a self, request: &mut Request<'a>) ``` -------------------------------- ### Sync Post Method Source: https://docs.rs/warp10/2.0.0/warp10/struct.Writer.html Synchronously sends a vector of Data using the Writer. Returns a Result containing a Warp10Response. ```rust pub fn post_sync(&self, data: Vec) -> Result ``` -------------------------------- ### Using expect() to Unwrap Result with Panic Source: https://docs.rs/warp10/2.0.0/warp10/type.Result.html Shows how to retrieve the Ok value from a Result, panicking with a custom message if it's an Err. Use with caution. ```rust let x: Result = Err("emergency failure"); x.expect("Testing expect"); // panics with `Testing expect: emergency failure` ``` -------------------------------- ### Async Post Method Source: https://docs.rs/warp10/2.0.0/warp10/struct.Writer.html Asynchronously sends a vector of Data using the Writer. Returns a Result containing a Warp10Response. ```rust pub async fn post(&self, data: Vec) -> Result ``` -------------------------------- ### Data::new Source: https://docs.rs/warp10/2.0.0/warp10/struct.Data.html Constructs a new Data instance with all fields, including a specific date. ```APIDOC ## pub fn new ### Description Creates a new `Data` instance, requiring a date, an optional geo value, a name, a vector of labels, and a value. ### Signature ```rust pub fn new(date: OffsetDateTime, geo: Option, name: String, labels: Vec