### Rust Example Search Patterns Source: https://docs.rs/mbus-api/latest/mbus_api/client/enum.HyperClient_search= Provides examples of common search patterns used within the MBus API context. These examples illustrate how to search for specific types, type conversions, and generic function signatures. ```rust std::vec ``` ```rust u32 -> bool ``` ```rust Option, (T -> U) -> Option ``` -------------------------------- ### Get Data from MBus Device Source: https://docs.rs/mbus-api/latest/mbus_api/trait.Api_search=std%3A%3Avec Implements the `get` method for retrieving data from a specified MBus device. It requires device details, baudrate, address, and a context. Returns a `GetResponse` or an `ApiError`. ```rust fn get<'life0, 'life1, 'async_trait>( &'life0 self, device: String, baudrate: Baudrate, address: String, context: &'life1 C, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; ``` -------------------------------- ### Initialize HTTPS Client Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client Creates a client configured for TLS connections to the server. This ensures secure communication over HTTPS. It requires the base path of the API, which should start with 'https://'. ```rust pub fn try_new_https(base_path: &str) -> Result ``` -------------------------------- ### Blanket Implementations for Generic Types in Rust Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Maxframes Showcases blanket implementations for generic types, demonstrating how traits can be implemented for any type that satisfies certain bounds. Examples include implementations for Any, Borrow, BorrowMut, CloneToUninit, From for T, and Instrument. ```rust impl Any for T where T: 'static + ?Sized, fn type_id(&self) -> TypeId impl Borrow for T where T: ?Sized, fn borrow(&self) -> &T impl BorrowMut for T where T: ?Sized, fn borrow_mut(&mut self) -> &mut T impl CloneToUninit for T where T: Clone, unsafe fn clone_to_uninit(&self, dest: *mut u8) impl From for T fn from(t: T) -> T impl Instrument for T fn instrument(self, span: Span) -> Instrumented fn in_current_span(self) -> Instrumented ``` -------------------------------- ### Get String Length in Bytes Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Device Returns the length of the string in bytes. This is not necessarily the number of characters or graphemes. For example, multi-byte UTF-8 characters will contribute more than one byte to the length. ```rust let len = "foo".len(); assert_eq!(3, len); assert_eq!("ƒoo".len(), 4); // fancy f! assert_eq!("ƒoo".chars().count(), 3); ``` -------------------------------- ### Initialize Client with Service Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client Constructs a `Client` by providing a pre-configured `hyper::service::Service` or `tower::Service`. This allows for advanced customization, such as adding middleware for logging or other request/response processing. ```rust pub fn try_new_with_client_service( client_service: S, base_path: &str, ) -> Result ``` -------------------------------- ### Rust: Get Mutable Subslice (Safe) Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Yaml_search=u32+-%3E+bool Returns a mutable subslice of a string slice using safe indexing. This is the non-panicking alternative to mutable indexing. It returns `None` if the index is out of bounds. The example shows how to modify the subslice. ```rust pub fn get_mut( &mut self, i: I, ) -> Option<&mut >::Output> where I: SliceIndex, ``` ```rust let mut v = String::from("hello"); // correct length assert!(v.get_mut(0..5).is_some()); // out of bounds assert!(v.get_mut(..42).is_none()); assert_eq!(Some("he"), v.get_mut(0..2).map(|v| &*v)); assert_eq!("hello", v); { let s = v.get_mut(0..2); let s = s.map(|s| { s.make_ascii_uppercase(); &*s }); assert_eq!(Some("HE"), s); } assert_eq!("HEllo", v); ``` -------------------------------- ### Compare Device Instances Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Device_search=u32+-%3E+bool This section details the implementations for comparing `Device` instances for equality (`PartialEq`) and ordering (`PartialOrd`). It includes methods for checking equality (`eq`, `ne`), less than (`lt`), less than or equal to (`le`), greater than (`gt`), and greater than or equal to (`ge`). ```rust impl PartialEq for Device { fn eq(&self, other: &Device) -> bool; fn ne(&self, other: &Rhs) -> bool; } impl PartialOrd for Device { fn partial_cmp(&self, other: &Device) -> Option; fn lt(&self, other: &Rhs) -> bool; fn le(&self, other: &Rhs) -> bool; fn gt(&self, other: &Rhs) -> bool; fn ge(&self, other: &Rhs) -> bool; } ``` -------------------------------- ### Rust: Get Mutable Subslice (Safe) Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.MbusData_search=u32+-%3E+bool Retrieves a mutable subslice of a string using a safe indexing operation. Returns `Some` with the mutable subslice if the index is valid, or `None` if the index would cause a panic. Provides examples of modifying the subslice. ```Rust #### pub fn get_mut( &mut self, i: I, ) -> Option<&mut >::Output> where I: SliceIndex, ``` ```Rust let mut v = String::from("hello"); // correct length assert!(v.get_mut(0..5).is_some()); // out of bounds assert!(v.get_mut(..42).is_none()); assert_eq!(Some("he"), v.get_mut(0..2).map(|v| &*v)); assert_eq!("hello", v); { let s = v.get_mut(0..2); let s = s.map(|s| { s.make_ascii_uppercase(); &*s }); assert_eq!(Some("HE"), s); } assert_eq!("HEllo", v); ``` -------------------------------- ### Initialize HTTP Client Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client Creates a standard HTTP client. This is the simplest way to initialize a client for making requests over HTTP. It requires only the base path of the API. ```rust pub fn try_new(base_path: &str) -> Result ``` -------------------------------- ### Get TypeId of a Type Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Device_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the Any trait, providing a method to get the `TypeId` of a type. This is part of Rust's dynamic typing capabilities. ```rust impl Any for T where T: 'static + ?Sized { fn type_id(&self) -> TypeId { // Implementation details... } } ``` -------------------------------- ### Initialize HTTP Client (Alternative) Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client An alternative method to create an HTTP client, likely using a specific internal configuration or dependency. It also requires the base path of the API. ```rust pub fn try_new_http(base_path: &str) -> Result ``` -------------------------------- ### Initialize Client with Custom Connector Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client Creates a client using a custom `hyper::client::Connect` implementation. This is useful for advanced scenarios like protocol logging or wrapping the transport layer. It requires a base path, an optional protocol string, and the custom connector. ```rust pub fn try_new_with_connector( base_path: &str, protocol: Option<&'static str>, connector: Connector, ) -> Result ``` -------------------------------- ### Finding Match Indices with match_indices and rmatch_indices in Rust Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Address_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the `match_indices` and `rmatch_indices` methods, which return iterators yielding tuples of the starting index and the matched substring. `match_indices` searches from the start, and `rmatch_indices` searches from the end. ```rust let v: Vec<_> = "abcXXXabcYYYabc".match_indices("abc").collect(); assert_eq!(v, [(0, "abc"), (6, "abc"), (12, "abc")]); let v: Vec<_> = "1abcabc2".match_indices("abc").collect(); assert_eq!(v, [(1, "abc"), (4, "abc")]); let v: Vec<_> = "ababa".match_indices("aba").collect(); assert_eq!(v, [(0, "aba")]); // only the first `aba` let v: Vec<_> = "abcXXXabcYYYabc".rmatch_indices("abc").collect(); assert_eq!(v, [(12, "abc"), (6, "abc"), (0, "abc")]); let v: Vec<_> = "1abcabc2".rmatch_indices("abc").collect(); assert_eq!(v, [(4, "abc"), (1, "abc")]); let v: Vec<_> = "ababa".rmatch_indices("aba").collect(); assert_eq!(v, [(2, "aba")]); // only the last `aba` ``` -------------------------------- ### Create Client with Service Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client_search= Constructs a `Client` by providing a pre-configured `hyper::service::Service` or `tower::Service`. This allows for advanced customization, such as adding logging wrappers around the transport layer. ```rust pub fn try_new_with_client_service( client_service: S, base_path: &str, ) -> Result ``` -------------------------------- ### Compare Device Equality Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Device_search=std%3A%3Avec This implementation of `PartialEq` for `Device` defines how two `Device` instances are compared for equality. It provides the `eq` method for checking equality (`==`) and the `ne` method for checking inequality (`!=`). ```rust impl PartialEq for Device { fn eq(&self, other: &Device) -> bool { // ... implementation details ... } fn ne(&self, other: &Rhs) -> bool { // ... implementation details ... } } ``` -------------------------------- ### Get ASCII Slice from String (Experimental) in Rust Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.TextError Provides a way to get a slice of ASCII characters from a string if it's confirmed to be ASCII. This is an experimental, nightly-only API. It returns `None` if the string contains non-ASCII characters. ```rust let ascii_string = "hello"; let ascii_slice = ascii_string.as_ascii(); assert!(ascii_slice.is_some()); let non_ascii_string = "你好"; let non_ascii_slice = non_ascii_string.as_ascii(); assert!(non_ascii_slice.is_none()); ``` -------------------------------- ### Get ASCII Slice Representation in Rust (Experimental) Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Address_search= Provides a way to get a slice of ASCII characters from a string if it's confirmed to be ASCII. This is an experimental, nightly-only API. `as_ascii` returns an `Option`, while `as_ascii_unchecked` provides direct access but requires manual safety guarantees. ```rust // This is an experimental API and requires nightly Rust. // let ascii_str = "hello"; // if let Some(ascii_chars) = ascii_str.as_ascii() { // // Process ascii_chars // } // // // Safety: The caller must ensure all characters are ASCII. // let ascii_chars_unchecked = unsafe { ascii_str.as_ascii_unchecked() }; ``` -------------------------------- ### Compare Device Ordering Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Device_search=std%3A%3Avec This implementation of `PartialOrd` for `Device` defines the ordering relationships between `Device` instances. It includes methods for less than (`lt`), less than or equal to (`le`), greater than (`gt`), and greater than or equal to (`ge`), as well as `partial_cmp` for a general comparison. ```rust impl PartialOrd for Device { fn partial_cmp(&self, other: &Device) -> Option { // ... implementation details ... } fn lt(&self, other: &Rhs) -> bool { // ... implementation details ... } fn le(&self, other: &Rhs) -> bool { // ... implementation details ... } fn gt(&self, other: &Rhs) -> bool { // ... implementation details ... } fn ge(&self, other: &Rhs) -> bool { // ... implementation details ... } } ``` -------------------------------- ### Safely Get Mutable String Subslice (Rust) Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Address Returns a non-panicking mutable subslice of a string slice. Similar to `get`, it uses `SliceIndex` for indexing and returns `None` on invalid indices. Modifications must maintain UTF-8 validity. Available since Rust 1.20.0. ```rust pub fn get_mut(&mut self, i: I) -> Option<&mut >::Output> where I: SliceIndex, ``` -------------------------------- ### Compare Device Ordering Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Device Implements partial ordering for `Device` instances. This allows comparing `Device` objects using operators like `<`, `<=`, `>`, and `>=`. The `partial_cmp` method returns an `Option`. ```rust impl PartialOrd for Device { fn partial_cmp(&self, other: &Device) -> Option; fn lt(&self, other: &Rhs) -> bool; fn le(&self, other: &Rhs) -> bool; fn gt(&self, other: &Rhs) -> bool; fn ge(&self, other: &Rhs) -> bool; } ``` -------------------------------- ### starts_with() Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Slaves_search=std%3A%3Avec Checks if the string slice starts with a given pattern. ```APIDOC ## starts_with() ### Description Returns `true` if the given pattern matches a prefix of this string slice. Returns `false` if it does not. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ### Response Example N/A ``` -------------------------------- ### CloneToUninit for Clone Types (Nightly) Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Device_search=std%3A%3Avec This nightly-only experimental API provides an unsafe method `clone_to_uninit` for types that implement `Clone`. It performs copy-assignment from `self` to a raw pointer destination. ```rust impl CloneToUninit for T where T: Clone { unsafe fn clone_to_uninit(&self, dest: *mut u8) { // ... implementation details ... } } ``` -------------------------------- ### Get mutable byte vector from Rust String Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Device Provides an unsafe method to get a mutable reference to the underlying byte vector of a String. This allows direct manipulation of bytes but requires care to maintain UTF-8 validity, as violating this can lead to memory safety issues. ```rust let mut s = String::from("hello"); unsafe { let vec = s.as_mut_vec(); assert_eq!(&[104, 101, 108, 108, 111][..], &vec[..]); vec.reverse(); } assert_eq!(s, "olleh"); ``` -------------------------------- ### GET /api/mbus Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client Retrieves general MBus API information. ```APIDOC ## GET /api/mbus ### Description Retrieves general information about the MBus API. ### Method GET ### Endpoint /api/mbus ### Response #### Success Response (200) - **response** (MbusApiResponse) - General MBus API information. #### Response Example ```json { "response": { ... } } ``` ``` -------------------------------- ### Implement CloneToUninit in Rust (Nightly) Source: https://docs.rs/mbus-api/latest/mbus_api/server/struct.Service_search=u32+-%3E+bool Details the experimental nightly-only implementation of `CloneToUninit`. This unsafe function allows cloning data into uninitialized memory, requiring careful usage. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Create MakeService Instance in Rust Source: https://docs.rs/mbus-api/latest/mbus_api/server/struct.MakeService Provides a constructor function `new` for the `MakeService` struct. This function takes an implementation of the `Api` trait (`api_impl`) and returns a new `MakeService` instance. ```rust pub fn new(api_impl: T) -> Self ``` -------------------------------- ### rsplitn Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Address_search= Splits a string slice into at most `n` substrings by a pattern, starting from the end. ```APIDOC ## rsplitn ### Description Returns an iterator over substrings of this string slice, separated by a pattern, starting from the end of the string, restricted to returning at most `n` items. If `n` substrings are returned, the last substring will contain the remainder of the string. ### Method `rsplitn` ### Endpoint N/A (This is a method on string slices) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust // Example for rsplitn is not provided in the source text. // Assuming similar behavior to splitn but from the end. // let v: Vec<&str> = "Mary had a little lambda".rsplitn(3, ' ').collect(); // assert_eq!(v, ["lambda", "little", "Mary had a"]); ``` ### Response #### Success Response (200) An iterator yielding at most `n` string slices in reverse order. #### Response Example ```json ["lambda", "little", "Mary had a"] ``` ``` -------------------------------- ### UTF-16 Encoding API Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Yaml_search=u32+-%3E+bool Provides a method to get an iterator over the string encoded as UTF-16. ```APIDOC ## GET /encode_utf16 ### Description Returns an iterator of `u16` over the string encoded as native endian UTF-16 (without byte-order mark). ### Method GET ### Endpoint /encode_utf16 ### Parameters #### Query Parameters - **text** (string) - Required - The input string to encode. ### Request Example ```json { "text": "Zażółć gęślą jaźń" } ``` ### Response #### Success Response (200) - **utf16_values** (array) - An array of numbers representing the UTF-16 code units. #### Response Example ```json { "utf16_values": [ 90, 380, 410, 322, 322, 322, 280, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 3 ``` -------------------------------- ### UTF-16 Encoding API Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.MbusData_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides a method to get an iterator over the string encoded as UTF-16. ```APIDOC ## GET /encode/utf16 ### Description Returns an iterator of `u16` over the string encoded as native endian UTF-16 (without byte-order mark). ### Method GET ### Endpoint /encode/utf16 ### Parameters None ### Request Example None ### Response #### Success Response (200) - **iterator** (EncodeUtf16) - An iterator yielding `u16` values representing the UTF-16 encoding. #### Response Example ``` let text = "Zażółć gęślą jaźń"; let utf8_len = text.len(); let utf16_len = text.encode_utf16().count(); assert!(utf16_len <= utf8_len); ``` ``` -------------------------------- ### Initialize HTTPS Client with Pinned Certificate Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client Creates a client for TLS connections using a pinned server certificate for enhanced security. This method requires the base path and the path to the CA certificate used for server authentication. ```rust pub fn try_new_https_pinned( base_path: &str, ca_certificate: CA, ) -> Result where CA: AsRef, ``` -------------------------------- ### GET /api/mbus/scan Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client Scans for available MBus devices. Requires device and baudrate. ```APIDOC ## GET /api/mbus/scan ### Description Scans for available MBus devices on the specified interface and baud rate. ### Method GET ### Endpoint /api/mbus/scan ### Query Parameters - **device** (string) - Required - The interface to scan on (e.g., serial port name). - **baudrate** (Baudrate) - Required - The baud rate to use for scanning. ### Response #### Success Response (200) - **response** (ScanResponse) - A list of discovered MBus devices. #### Response Example ```json { "response": { ... } } ``` ``` -------------------------------- ### Implement CloneToUninit in Rust (Nightly) Source: https://docs.rs/mbus-api/latest/mbus_api/server/struct.Service_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Illustrates the `clone_to_uninit` method from the nightly-only experimental `CloneToUninit` trait. This unsafe method allows copying data to an uninitialized memory location. ```rust impl CloneToUninit for T where T: Clone, { unsafe fn clone_to_uninit(&self, dest: *mut u8) } ``` -------------------------------- ### GET /api/mbus/hat Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client Retrieves the current status of the HAT (Hardware Access Terminal). ```APIDOC ## GET /api/mbus/hat ### Description Retrieves the current status of the HAT (Hardware Access Terminal). ### Method GET ### Endpoint /api/mbus/hat ### Response #### Success Response (200) - **response** (HatResponse) - The status of the HAT. #### Response Example ```json { "response": { ... } } ``` ``` -------------------------------- ### Compare Device Instances for Ordering Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Device_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the PartialOrd trait for Device, allowing for partial ordering comparisons between Device instances using `<`, `<=`, `>`, and `>=` operators. ```rust impl PartialOrd for Device { fn partial_cmp(&self, other: &Device) -> Option { // Implementation details... } fn lt(&self, other: &Rhs) -> bool { // Implementation details... } fn le(&self, other: &Rhs) -> bool { // Implementation details... } fn gt(&self, other: &Rhs) -> bool { // Implementation details... } fn ge(&self, other: &Rhs) -> bool { // Implementation details... } } ``` -------------------------------- ### Implement Blanket Services for Generic Types in Rust Source: https://docs.rs/mbus-api/latest/mbus_api/context/struct.MakeAddContext_search= Showcases various blanket implementations provided for generic types in Rust, which are applicable to `MakeAddContext` and its components. These include implementations for `Any`, `Borrow`, `BorrowMut`, `CompositedMakeService`, `From`, `Instrument`, `Into`, `TryFrom`, `TryInto`, and `WithSubscriber`, enabling broader interoperability and functionality. ```rust impl Any for T where T: 'static + ?Sized impl Borrow for T where T: ?Sized impl BorrowMut for T where T: ?Sized impl CompositedMakeService for T where Target: Send, T: Service + Send, F: Future> + Send + 'static, S: CompositedService + Send + 'static impl From for T impl Instrument for T impl Into for T where U: From impl TryFrom for T where U: Into impl TryInto for T where U: TryFrom impl WithSubscriber for T ``` -------------------------------- ### GET /api/mbus/get Source: https://docs.rs/mbus-api/latest/mbus_api/client/struct.Client Retrieves data from an MBus device. Requires device, baudrate, and address. ```APIDOC ## GET /api/mbus/get ### Description Retrieves data from a specified MBus device. ### Method GET ### Endpoint /api/mbus/get ### Query Parameters - **device** (string) - Required - The identifier for the MBus device. - **baudrate** (Baudrate) - Required - The baud rate for the MBus communication. - **address** (string) - Required - The address of the MBus device. ### Response #### Success Response (200) - **response** (GetResponse) - The data retrieved from the MBus device. #### Response Example ```json { "response": { ... } } ``` ``` -------------------------------- ### Generic Implementations for Address (Rust) Source: https://docs.rs/mbus-api/latest/mbus_api/models/struct.Address_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Showcases various auto-trait and blanket implementations for the Address type, including `Freeze`, `RefUnwindSafe`, `Send`, `Sync`, `Unpin`, `UnwindSafe`, `Any`, `Borrow`, `BorrowMut`, `CloneToUninit`, `From`, `Instrument`, `Into`, `Receiver`, `ToOwned`, and `TryFrom`. ```Rust impl Freeze for Address impl RefUnwindSafe for Address impl Send for Address impl Sync for Address impl Unpin for Address impl UnwindSafe for Address ``` ```Rust impl Any for T where T: 'static + ?Sized, fn type_id(&self) -> TypeId ``` ```Rust impl Borrow for T where T: ?Sized, fn borrow(&self) -> &T ``` ```Rust impl BorrowMut for T where T: ?Sized, fn borrow_mut(&mut self) -> &mut T ``` ```Rust impl CloneToUninit for T where T: Clone, unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` ```Rust impl From for T fn from(t: T) -> T ``` ```Rust impl Instrument for T fn instrument(self, span: Span) -> Instrumented fn in_current_span(self) -> Instrumented ``` ```Rust impl Into for T where U: From, fn into(self) -> U ``` ```Rust impl Receiver for P where P: Deref + ?Sized, T: ?Sized, type Target = T ``` ```Rust impl ToOwned for T where T: Clone, type Owned = T fn to_owned(&self) -> T fn clone_into(&self, target: &mut T) ``` ```Rust impl TryFrom for T where U: Into ```