### Install a Holochain App Source: https://docs.rs/holochain_client/latest/holochain_client/struct.AdminWebsocket Installs a new Holochain application using the provided installation payload. Returns information about the newly installed app. ```rust pub async fn install_app( &self, payload: InstallAppPayload, ) -> ConductorApiResult ``` -------------------------------- ### Install Application Source: https://docs.rs/holochain_client/latest/holochain_client/struct.AdminWebsocket_search=u32+-%3E+bool Installs an application onto the Holochain conductor. This function takes an `InstallAppPayload` which contains the necessary information to deploy and configure the application. It returns `AppInfo` upon successful installation. ```rust pub async fn install_app( &self, payload: InstallAppPayload, ) -> ConductorApiResult ``` -------------------------------- ### List Installed Applications Source: https://docs.rs/holochain_client/latest/holochain_client/struct.AdminWebsocket_search=u32+-%3E+bool Lists all installed applications on the conductor. An optional `status_filter` can be provided to filter the list based on application status. Returns a `Vec` containing details of the applications. ```rust pub async fn list_apps( &self, status_filter: Option, ) -> ConductorApiResult> ``` -------------------------------- ### String Conversion from Iterator Example Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search= This example shows how to create a String from a single character. It demonstrates the `From` trait implementation, which allocates an owned String from a character. ```rust let c: char = 'a'; let s: String = String::from(c); assert_eq!("a", &s[..]); ``` -------------------------------- ### InstallAppPayload Structure Source: https://docs.rs/holochain_client/latest/holochain_client/struct.InstallAppPayload_search= Defines the structure for installing an application, including its source, agent key, and optional settings. ```APIDOC ## Struct InstallAppPayload ### Description All the information necessary to install an app. ### Fields - **source** (AppBundleSource) - Required - Where to obtain the AppBundle, which contains the app manifest and DNA bundles to be installed. This is the main payload of app installation. - **agent_key** (Option>) - Optional - The agent to use when creating Cells for this App. If None, a new agent key will be generated. - **installed_app_id** (Option) - Optional - The unique identifier for an installed app in this conductor. If not specified, it will be derived from the app name in the bundle manifest. - **network_seed** (Option) - Optional - Overwrites all network seeds for all DNAs of Cells created by this app. This has a lower precedence than role-specific network seeds provided in the `role_settings` field of the `InstallAppPayload`. The app can still use existing Cells, i.e. this does not require that all Cells have DNAs with the same overridden DNA. - **roles_settings** (Option>) - Optional - Specify role specific settings or modifiers that will override any settings in the dna manifets. - **ignore_genesis_failure** (bool) - Optional - If app installation fails due to genesis failure, normally the app will be immediately uninstalled. When this flag is set, the app is left installed with empty cells intact. This can be useful for using `graft_records_onto_source_chain`, or for diagnostics. ### Trait Implementations - **Clone**: Allows duplication of the `InstallAppPayload`. - **Debug**: Enables formatting the `InstallAppPayload` for debugging. - **Deserialize**: Allows deserialization of `InstallAppPayload` from a Serde deserializer. - **Serialize**: Allows serialization of `InstallAppPayload` to a Serde serializer. ### Auto Trait Implementations - **!Freeze, RefUnwindSafe, Send, Sync, Unpin, UnwindSafe** ``` -------------------------------- ### InstallAppPayload Structure Source: https://docs.rs/holochain_client/latest/holochain_client/struct.InstallAppPayload Details the structure of InstallAppPayload, used for installing Holochain applications. It includes information about the app's source, agent key, unique identifier, network settings, role-specific configurations, and error handling preferences during installation. ```APIDOC ## Struct InstallAppPayload ### Description All the information necessary to install an app. ### Fields * **source** (AppBundleSource) - Required - Where to obtain the AppBundle, which contains the app manifest and DNA bundles to be installed. This is the main payload of app installation. * **agent_key** (Option>) - Optional - The agent to use when creating Cells for this App. If None, a new agent key will be generated. * **installed_app_id** (Option) - Optional - The unique identifier for an installed app in this conductor. If not specified, it will be derived from the app name in the bundle manifest. * **network_seed** (Option) - Optional - Overwrites all network seeds for all DNAs of Cells created by this app. This has a lower precedence than role-specific network seeds provided in the `role_settings` field of the `InstallAppPayload`. The app can still use existing Cells, i.e. this does not require that all Cells have DNAs with the same overridden DNA. * **roles_settings** (Option>) - Optional - Specify role specific settings or modifiers that will override any settings in the dna manifets. * **ignore_genesis_failure** (bool) - Optional - If app installation fails due to genesis failure, normally the app will be immediately uninstalled. When this flag is set, the app is left installed with empty cells intact. This can be useful for using `graft_records_onto_source_chain`, or for diagnostics. ``` -------------------------------- ### InstallAppPayload Structure Source: https://docs.rs/holochain_client/latest/holochain_client/struct.InstallAppPayload_search=std%3A%3Avec This structure defines the payload required for installing an application within the Holochain conductor. ```APIDOC ## Struct InstallAppPayload ### Description All the information necessary to install an app. ### Fields - **source** (`AppBundleSource`) - Required - Where to obtain the AppBundle, which contains the app manifest and DNA bundles to be installed. This is the main payload of app installation. - **agent_key** (`Option>`) - Optional - The agent to use when creating Cells for this App. If None, a new agent key will be generated. - **installed_app_id** (`Option`) - Optional - The unique identifier for an installed app in this conductor. If not specified, it will be derived from the app name in the bundle manifest. - **network_seed** (`Option`) - Optional - Overwrites all network seeds for all DNAs of Cells created by this app. This has a lower precedence than role-specific network seeds provided in the `role_settings` field of the `InstallAppPayload`. The app can still use existing Cells, i.e. this does not require that all Cells have DNAs with the same overridden DNA. - **roles_settings** (`Option>`) - Optional - Specify role specific settings or modifiers that will override any settings in the dna manifets. - **ignore_genesis_failure** (`bool`) - Optional - If app installation fails due to genesis failure, normally the app will be immediately uninstalled. When this flag is set, the app is left installed with empty cells intact. This can be useful for using `graft_records_onto_source_chain`, or for diagnostics. ### Trait Implementations - **Clone**: Allows duplicating the `InstallAppPayload`. - `clone()`: Returns a duplicate of the value. - `clone_from()`: Performs copy-assignment from `source`. - **Debug**: Formats the value for debugging. - `fmt()`: Formats the value using the given formatter. - **Deserialize**: Allows deserializing `InstallAppPayload` from a Serde deserializer. - `deserialize()`: Deserializes this value from the given Serde deserializer. - **Serialize**: Allows serializing `InstallAppPayload` to a Serde serializer. - `serialize()`: Serializes this value into the given Serde serializer. ### Auto Trait Implementations - `!Freeze` - `RefUnwindSafe` - `Send` - `Sync` - `Unpin` - `UnwindSafe` ### Blanket Implementations - **Any**: Gets the `TypeId` of `self`. - **Borrow**: Immutably borrows from an owned value. - **BorrowMut**: Mutably borrows from an owned value. - **CloneToUninit**: (Nightly-only experimental API) Performs copy-assignment from `self` to `dest`. - **DynClone**: Box cloning functionality. - **From**: Returns the argument unchanged. - **FutureExt**: Extends `Future` with context-related methods. - `with_context()`: Attaches the provided `Context` to this type. - `with_current_context()`: Attaches the current `Context` to this type. - **Instrument**: Instruments types with `Span` for tracing. - `instrument()`: Instruments this type with the provided `Span`. - `in_current_span()`: Instruments this type with the current `Span`. - **Into**: Converts to another type if `From` implementation exists. - **IntoEither**: Converts into an `Either` type. ``` -------------------------------- ### Enable Application Source: https://docs.rs/holochain_client/latest/holochain_client/struct.AdminWebsocket_search=u32+-%3E+bool Enables a previously installed and possibly disabled application. Requires the `installed_app_id`. Returns an `EnableAppResponse` on success. ```rust pub async fn enable_app( &self, installed_app_id: String, ) -> ConductorApiResult ``` -------------------------------- ### TryFrom and TryInto Conversions Source: https://docs.rs/holochain_client/latest/holochain_client/struct.InstallAppPayload_search=std%3A%3Avec Traits for attempting conversions that may fail. ```APIDOC ## TryFrom and TryInto Conversions ### `impl TryFrom for T` #### `type Error = Infallible` The type returned in the event of a conversion error. #### `fn try_from(value: U) -> Result>::Error>` Performs the conversion. ### `impl TryInto for T` #### `type Error = >::Error` The type returned in the event of a conversion error. #### `fn try_into(self) -> Result>::Error>` Performs the conversion. ``` -------------------------------- ### Rust: Get Mutable String Slice Reference Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search= Explains how to get a mutable reference to a string slice (`&mut str`) from a `String`, allowing in-place modification of the string's content. The example shows converting to uppercase directly on the mutable slice. ```Rust let mut s = String::from("foobar"); let s_mut_str = s.as_mut_str(); s_mut_str.make_ascii_uppercase(); assert_eq!("FOOBAR", s_mut_str); ``` -------------------------------- ### Get Mutable Reference Unchecked with Arc in Rust Source: https://docs.rs/holochain_client/latest/holochain_client/type.DynAgentSigner_search= This Rust example shows the usage of `Arc::get_mut_unchecked`, which is an unsafe operation. This function provides a mutable reference to the data within an `Arc` without checking for other references. The example highlights the safety considerations and potential for undefined behavior if not used carefully, including examples of misuse and the resulting memory safety issues. ```rust #![feature(get_mut_unchecked)] use std::sync::Arc; let mut x = Arc::new(String::new()); unsafe { Arc::get_mut_unchecked(&mut x).push_str("foo") } assert_eq!(*x, "foo"); ``` ```rust #![feature(get_mut_unchecked)] use std::sync::Arc; let x: Arc = Arc::from("Hello, world!"); let mut y: Arc<[u8]> = x.clone().into(); unsafe { // this is Undefined Behavior, because x's inner type is str, not [u8] Arc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8 } println!("{}", &*x); // Invalid UTF-8 in a str ``` ```rust #![feature(get_mut_unchecked)] use std::sync::Arc; let x: Arc<&str> = Arc::new("Hello, world!"); { let s = String::from("Oh, no!"); let mut y: Arc<&str> = x.clone(); unsafe { // this is Undefined Behavior, because x's inner type // is &'long str, not &'short str *Arc::get_mut_unchecked(&mut y) = &s; } } println!("{}", &*x); // Use-after-free ``` -------------------------------- ### String Conversion from References and Other Types Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Documentation for converting various types into a `String`. ```APIDOC ## String Conversion from References and Other Types ### Description Demonstrates how to convert different types into an owned `String`. ### Methods #### `String::from(s: &String) -> String` - **Description**: Converts a `&String` into a `String` by cloning. - **Availability**: Available on **non-`no_global_oom_handling`** only. #### `String::from(s: &mut str) -> String` - **Description**: Converts a `&mut str` into a `String`. The result is allocated on the heap. - **Availability**: Available on **non-`no_global_oom_handling`** only. #### `String::from(s: &str) -> String` - **Description**: Converts a `&str` into a `String`. The result is allocated on the heap. - **Availability**: Available on **non-`no_global_oom_handling`** only. #### `String::from(value: AllowedOrigins) -> String` - **Description**: Converts an `AllowedOrigins` type into a `String`. #### `String::from(s: Box) -> String` - **Description**: Converts a boxed `str` slice into an owned `String`. The `str` slice is owned. ##### Example ```rust let s1: String = String::from("hello world"); let s2: Box = s1.into_boxed_str(); let s3: String = String::from(s2); assert_eq!("hello world", s3) ``` #### `String::from(s: Cow<'a, str>) -> String` - **Description**: Converts a clone-on-write string (`Cow<'a, str>`) to an owned `String`. If the `Cow` is borrowed, it will allocate on the heap and copy the string; otherwise, it takes ownership. - **Availability**: Available on **non-`no_global_oom_handling`** only. ##### Example ```rust use std::borrow::Cow; // If the string is not owned... let cow: Cow<'_, str> = Cow::Borrowed("eggplant"); // It will allocate on the heap and copy the string. let owned: String = String::from(cow); assert_eq!(&owned[..], "eggplant"); ``` #### `String::from(function_name: FunctionName) -> String` - **Description**: Converts a `FunctionName` type into a `String`. #### `String::from(key: Key) -> String` - **Description**: Converts a `Key` type into a `String`. #### `String::from(sb: SerializedBytesError) -> String` - **Description**: Converts a `SerializedBytesError` type into a `String`. ``` -------------------------------- ### Get Unchecked Mutable Reference from Arc Source: https://docs.rs/holochain_client/latest/holochain_client/type.DynAgentSigner This example demonstrates `get_mut_unchecked`, a nightly-only API for getting a mutable reference to the inner data of an `Arc`. It's unsafe and requires careful consideration of aliasing and type safety to prevent undefined behavior. Incorrect usage can lead to data corruption. ```rust #![feature(get_mut_unchecked)] use std::sync::Arc; let mut x = Arc::new(String::new()); unsafe { Arc::get_mut_unchecked(&mut x).push_str("foo") } assert_eq!(*x, "foo"); ``` -------------------------------- ### String Display Formatting Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Formats a String for display purposes. ```APIDOC ## POST /string/display_fmt ### Description Formats the String using the given formatter for display. ### Method POST ### Endpoint /string/display_fmt ### Parameters #### Request Body - **string_data** (String) - Required - The string to format. - **formatter** (Formatter<'_>) - Required - The formatter to use. ### Response #### Success Response (200) - **formatted_string** (String) - The display-formatted string. #### Response Example ```json { "formatted_string": "Displayed: example" } ``` ``` -------------------------------- ### Get Mutable Reference with Arc in Rust Source: https://docs.rs/holochain_client/latest/holochain_client/type.DynAgentSigner_search= This Rust example demonstrates the use of `Arc::get_mut` to get a mutable reference to the data within an `Arc`. It shows how to safely modify the data when there are no other references to the `Arc`. If there are other references, the function returns `None` to prevent unsafe shared mutable access. ```rust use std::sync::Arc; let mut x = Arc::new(3); *Arc::get_mut(&mut x).unwrap() = 4; assert_eq!(*x, 4); let _y = Arc::clone(&x); assert!(Arc::get_mut(&mut x).is_none()); ``` -------------------------------- ### Partial Ordering with String Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Provides methods for partial comparison between two Strings. ```APIDOC ## impl PartialOrd for String ### Description Provides methods for partial comparison between two Strings. ### Methods #### `partial_cmp(&self, other: &String) -> Option` This method returns an ordering between `self` and `other` values if one exists. #### `lt(&self, other: &Rhs) -> bool` Tests less than (for `self` and `other`) and is used by the `<` operator. #### `le(&self, other: &Rhs) -> bool` Tests less than or equal to (for `self` and `other`) and is used by the `<=` operator. #### `gt(&self, other: &Rhs) -> bool` Tests greater than (for `self` and `other`) and is used by the `>` operator. #### `ge(&self, other: &Rhs) -> bool` Tests greater than or equal to (for `self` and `other`) and is used by the `>=` operator. ``` -------------------------------- ### Rust: Accessing Metadata with and_then for Path Operations Source: https://docs.rs/holochain_client/latest/holochain_client/type.ConductorApiResult_search= Shows how to use `and_then` to chain fallible operations when working with file paths and metadata. This example attempts to get the modification time of a directory, 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); ``` -------------------------------- ### WebsocketConfig Default Client Configuration in Rust Source: https://docs.rs/holochain_client/latest/holochain_client/struct.WebsocketConfig Provides the default configuration for a WebSocket client. This includes a default request timeout and maximum sizes for messages and frames. It serves as a convenient starting point for client-side WebSocket setup. ```rust pub const CLIENT_DEFAULT: WebsocketConfig ``` -------------------------------- ### String Debug Formatting Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Formats a String for debugging purposes. ```APIDOC ## POST /string/debug_fmt ### Description Formats the String using the given formatter for debugging. ### Method POST ### Endpoint /string/debug_fmt ### Parameters #### Request Body - **string_data** (String) - Required - The string to format. - **formatter** (Formatter<'_>) - Required - The formatter to use. ### Response #### Success Response (200) - **formatted_string** (String) - The debug-formatted string. #### Response Example ```json { "formatted_string": "Debug: \"example\"" } ``` ``` -------------------------------- ### Partial Ordering with PathAndQuery Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Provides methods for partial comparison between a String and PathAndQuery. ```APIDOC ## impl PartialOrd ### Description Provides methods for partial comparison between a String and PathAndQuery. ### Methods #### `partial_cmp(&self, other: &PathAndQuery) -> Option` This method returns an ordering between `self` and `other` values if one exists. #### `lt(&self, other: &Rhs) -> bool` Tests less than (for `self` and `other`) and is used by the `<` operator. #### `le(&self, other: &Rhs) -> bool` Tests less than or equal to (for `self` and `other`) and is used by the `<=` operator. #### `gt(&self, other: &Rhs) -> bool` Tests greater than (for `self` and `other`) and is used by the `>` operator. #### `ge(&self, other: &Rhs) -> bool` Tests greater than or equal to (for `self` and `other`) and is used by the `>=` operator. ``` -------------------------------- ### Rust: Extend String with a Range Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search= Demonstrates extending a `String` by copying characters from a specified range within itself to its end. The example shows extending with a range from the start, from a middle point, and with a bounded range, highlighting its flexibility and potential for panics if range bounds are invalid or not on character boundaries. ```Rust let mut string = String::from("abcde"); string.extend_from_within(2..); assert_eq!(string, "abcdecde"); string.extend_from_within(..2); assert_eq!(string, "abcdecdeab"); string.extend_from_within(4..8); assert_eq!(string, "abcdecdeabecde"); ``` -------------------------------- ### Rust String as Mutable Byte Vector Example Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId Demonstrates how to get a mutable byte vector from a Rust String using `as_mut_vec`. This operation is unsafe and requires careful handling to maintain UTF-8 validity. It shows modifying the underlying bytes and observing the string's change. ```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"); ``` -------------------------------- ### String Default Value Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Creates an empty String. ```APIDOC ## GET /string/default ### Description Creates an empty String. ### Method GET ### Endpoint /string/default ### Response #### Success Response (200) - **default_string** (String) - An empty string. #### Response Example ```json { "default_string": "" } ``` ``` -------------------------------- ### StringBuilder Implementation Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Provides string building capabilities for a String. ```APIDOC ## impl<'s> StringBuilder<'s> for String ### Description Provides string building capabilities for a String. Available on `crate` feature `alloc` only. ``` -------------------------------- ### Ownership and Cloning Source: https://docs.rs/holochain_client/latest/holochain_client/struct.InstallAppPayload_search=std%3A%3Avec Traits and methods related to obtaining ownership and cloning of data. ```APIDOC ## Ownership and Cloning Traits ### `impl Same for T` #### `type Output = T` Should always be `Self`. ### `impl ToOwned for T` #### `type Owned = T` The resulting type after obtaining ownership. #### `fn to_owned(&self) -> T` Creates owned data from borrowed data, usually by cloning. #### `fn clone_into(&self, target: &mut T)` Uses borrowed data to replace owned data, usually by cloning. ``` -------------------------------- ### Define AppInfo Struct in Rust Source: https://docs.rs/holochain_client/latest/holochain_client/struct.AppInfo_search= Defines the AppInfo struct used to hold information about an installed Holochain application. It includes fields for the installed app ID, cell information, status, agent public key, manifest, and installation timestamp. This struct is essential for retrieving and managing installed applications within the conductor. ```rust pub struct AppInfo { pub installed_app_id: String, pub cell_info: IndexMap>, pub status: AppStatus, pub agent_pub_key: HoloHash, pub manifest: AppManifest, pub installed_at: Timestamp, } ``` -------------------------------- ### Partial Ordering with Bytes Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Provides methods for partial comparison between a String and Bytes. ```APIDOC ## impl PartialOrd ### Description Provides methods for partial comparison between a String and Bytes. ### Methods #### `partial_cmp(&self, other: &Bytes) -> Option` This method returns an ordering between `self` and `other` values if one exists. #### `lt(&self, other: &Rhs) -> bool` Tests less than (for `self` and `other`) and is used by the `<` operator. #### `le(&self, other: &Rhs) -> bool` Tests less than or equal to (for `self` and `other`) and is used by the `<=` operator. #### `gt(&self, other: &Rhs) -> bool` Tests greater than (for `self` and `other`) and is used by the `>` operator. #### `ge(&self, other: &Rhs) -> bool` Tests greater than or equal to (for `self` and `other`) and is used by the `>=` operator. ``` -------------------------------- ### Arc::into_inner Examples Source: https://docs.rs/holochain_client/latest/holochain_client/type.DynAgentSigner_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Examples demonstrating the usage and guarantee of `Arc::into_inner`. ```APIDOC ## `Arc::into_inner` Examples ### Description Minimal example demonstrating the guarantee that `Arc::into_inner` gives. ### Code Example ```rust use std::sync::Arc; let x = Arc::new(3); let y = Arc::clone(&x); // Two threads calling `Arc::into_inner` on both clones of an `Arc`: let x_thread = std::thread::spawn(|| Arc::into_inner(x)); let y_thread = std::thread::spawn(|| Arc::into_inner(y)); let x_inner_value = x_thread.join().unwrap(); let y_inner_value = y_thread.join().unwrap(); // One of the threads is guaranteed to receive the inner value: assert!(matches!( (x_inner_value, y_inner_value), (None, Some(3)) | (Some(3), None) )); // The result could also be `(None, None)` if the threads called // `Arc::try_unwrap(x).ok()` and `Arc::try_unwrap(y).ok()` instead. ``` ### Description A more practical example demonstrating the need for `Arc::into_inner`. ### Code Example ```rust use std::sync::Arc; // Definition of a simple singly linked list using `Arc`: #[derive(Clone)] struct LinkedList(Option>>); struct Node(T, Option>>); // Dropping a long `LinkedList` relying on the destructor of `Arc` // can cause a stack overflow. To prevent this, we can provide a // manual `Drop` implementation that does the destruction in a loop: impl Drop for LinkedList { fn drop(&mut self) { let mut link = self.0.take(); while let Some(arc_node) = link.take() { if let Some(Node(_value, next)) = Arc::into_inner(arc_node) { link = next; } } } } // Implementation of `new` and `push` omitted impl LinkedList { /* ... */ } // The following code could have still caused a stack overflow // despite the manual `Drop` impl if that `Drop` impl had used // `Arc::try_unwrap(arc).ok()` instead of `Arc::into_inner(arc)`. // Create a long list and clone it let mut x = LinkedList::new(); let size = 100000; for i in 0..size { x.push(i); // Adds i to the front of x } let y = x.clone(); // Drop the clones in parallel let x_thread = std::thread::spawn(|| drop(x)); let y_thread = std::thread::spawn(|| drop(y)); x_thread.join().unwrap(); y_thread.join().unwrap(); ``` ``` -------------------------------- ### ProvideMemproofs Source: https://docs.rs/holochain_client/latest/holochain_client/enum.AppRequest Provides membrane proofs for an app if it was installed with `allow_deferred_memproofs` and proofs were not supplied during installation. ```APIDOC ## ProvideMemproofs ### Description Provide the membrane proofs for this app, if this app was installed using `allow_deferred_memproofs` and memproofs were not provided at installation time. ### Method AppRequest::ProvideMemproofs ### Parameters #### Request Body - **memproofs** (HashMap>) - Required - A map of DNA names to their serialized membrane proofs. ### Returns `AppResponse::Ok` ``` -------------------------------- ### String Conversion to Bytes Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Converts a String to a byte slice. ```APIDOC ## GET /string/as_bytes ### Description Returns a byte slice of the String's contents. ### Method GET ### Endpoint /string/as_bytes ### Parameters #### Query Parameters - **content** (string) - Required - The string to convert. ### Request Example ``` /string/as_bytes?content=hello ``` ### Response #### Success Response (200) - **bytes** (array) - An array of byte values representing the string. #### Response Example ```json { "bytes": [104, 101, 108, 108, 111] } ``` ``` -------------------------------- ### Reserve Capacity for String Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec APIs for reserving additional capacity in a String. Note that some of these are nightly-only experimental APIs. ```APIDOC ## Reserve Capacity for String ### Description Methods to reserve capacity in a String for a specified number of additional elements. Some methods are marked as experimental and require a nightly Rust toolchain. ### Methods #### `extend_reserve(&mut self, additional: usize)` - **Description**: Reserves capacity in a collection for the given number of additional elements. - **Note**: Nightly-only experimental API. #### `extend_reserve(&mut self, additional: usize)` - **Description**: Reserves capacity in a collection for the given number of additional elements. - **Note**: Nightly-only experimental API. #### `extend_reserve(&mut self, additional: usize)` - **Description**: Reserves capacity in a collection for the given number of additional elements. - **Note**: Nightly-only experimental API. #### `extend_reserve(&mut self, additional: usize)` - **Description**: Reserves capacity in a collection for the given number of additional elements. - **Note**: Nightly-only experimental API. ``` -------------------------------- ### Arc Mutability Examples Source: https://docs.rs/holochain_client/latest/holochain_client/type.DynAgentSigner Examples demonstrating how to mutate data within an `Arc` using `make_mut` and `clone`. ```APIDOC ## Arc Mutability Examples ### Description Examples demonstrating how to mutate data within an `Arc` using `make_mut` and `clone`. ### Method N/A (Illustrative Examples) ### Endpoint N/A ### Parameters N/A ### Request Example ```rust use std::sync::Arc; let mut data = Arc::new(5); *Arc::make_mut(&mut data) += 1; // Won't clone anything let mut other_data = Arc::clone(&data); // Won't clone inner data *Arc::make_mut(&mut data) += 1; // Clones inner data *Arc::make_mut(&mut data) += 1; // Won't clone anything *Arc::make_mut(&mut other_data) *= 2; // Won't clone anything // Now `data` and `other_data` point to different allocations. assert_eq!(*data, 8); assert_eq!(*other_data, 12); ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Partial Ordering with BytesMut Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Provides methods for partial comparison between a String and BytesMut. ```APIDOC ## impl PartialOrd ### Description Provides methods for partial comparison between a String and BytesMut. ### Methods #### `partial_cmp(&self, other: &BytesMut) -> Option` This method returns an ordering between `self` and `other` values if one exists. #### `lt(&self, other: &Rhs) -> bool` Tests less than (for `self` and `other`) and is used by the `<` operator. #### `le(&self, other: &Rhs) -> bool` Tests less than or equal to (for `self` and `other`) and is used by the `<=` operator. #### `gt(&self, other: &Rhs) -> bool` Tests greater than (for `self` and `other`) and is used by the `>` operator. #### `ge(&self, other: &Rhs) -> bool` Tests greater than or equal to (for `self` and `other`) and is used by the `>=` operator. ``` -------------------------------- ### List Installed Holochain Applications Source: https://docs.rs/holochain_client/latest/holochain_client/struct.AdminWebsocket Retrieves a list of installed Holochain applications. An optional status filter can be provided to narrow down the results. ```rust pub async fn list_apps( &self, status_filter: Option, ) -> ConductorApiResult> ``` -------------------------------- ### Enable a Holochain App Source: https://docs.rs/holochain_client/latest/holochain_client/struct.AdminWebsocket Enables a previously installed Holochain application specified by its installed app ID. Returns a response indicating the success of the operation. ```rust pub async fn enable_app( &self, installed_app_id: String, ) -> ConductorApiResult ``` -------------------------------- ### String Dereferencing Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Provides dereferencing for String to &str. ```APIDOC ## GET /string/deref ### Description Dereferences the String value to a &str slice. ### Method GET ### Endpoint /string/deref ### Parameters #### Query Parameters - **string_data** (String) - Required - The string to dereference. ### Response #### Success Response (200) - **dereferenced_slice** (&str) - The string slice obtained by dereferencing. #### Response Example ```json { "dereferenced_slice": "dereferenced content" } ``` ## GET /string/deref_mut ### Description Mutably dereferences the String value to a &mut str slice. ### Method GET ### Endpoint /string/deref_mut ### Parameters #### Query Parameters - **string_data** (String) - Required - The string to mutably dereference. ### Response #### Success Response (200) - **dereferenced_mutable_slice** (&mut str) - The mutable string slice obtained by dereferencing. #### Response Example ```json { "dereferenced_mutable_slice": "mutable dereferenced content" } ``` ``` -------------------------------- ### String Query Methods Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec This section covers methods for querying information about Rust String objects, such as their length and emptiness. ```APIDOC ## String Query Methods ### Description This section covers methods for querying information about Rust String objects. ### Methods #### `len() -> usize` ##### Description Returns the length of this `String`, in bytes, not `char`s or graphemes. In other words, it might not be what a human considers the length of the string. ##### Method `len` ##### Endpoint N/A (Instance Method) ##### Parameters None ##### Request Example ```rust let a = String::from("foo"); assert_eq!(a.len(), 3); let fancy_f = String::from("ƒoo"); assert_eq!(fancy_f.len(), 4); assert_eq!(fancy_f.chars().count(), 3); ``` ##### Response ###### Success Response (200) Returns the length of the string in bytes. ###### Response Example ``` 3 ``` #### `is_empty() -> bool` ##### Description Returns `true` if this `String` has a length of zero, and `false` otherwise. ##### Method `is_empty` ##### Endpoint N/A (Instance Method) ##### Parameters None ##### Request Example ```rust let mut v = String::new(); assert!(v.is_empty()); v.push('a'); assert!(!v.is_empty()); ``` ##### Response ###### Success Response (200) Returns a boolean indicating if the string is empty. ###### Response Example ``` true ``` ``` -------------------------------- ### Manage Applications Source: https://docs.rs/holochain_client/latest/holochain_client/struct.AdminWebsocket_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides functionality to list, install, uninstall, enable, and disable applications within the Holochain conductor. Requires app IDs and installation payloads for specific operations. ```Rust pub async fn list_apps(&self, status_filter: Option) -> ConductorApiResult> ``` ```Rust pub async fn install_app(&self, payload: InstallAppPayload) -> ConductorApiResult ``` ```Rust pub async fn uninstall_app(&self, installed_app_id: String, force: bool) -> ConductorApiResult<()> ``` ```Rust pub async fn enable_app(&self, installed_app_id: String) -> ConductorApiResult ``` ```Rust pub async fn disable_app(&self, installed_app_id: String) -> ConductorApiResult<()> ``` -------------------------------- ### String Creation from Various Types (`From` Trait Implementations) Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to create a `String` from different input types using the `From` trait. ```APIDOC ## String Creation (`From` Trait Implementations) ### `impl From<&String> for String` #### `fn from(s: &String) -> String` * **Description**: Converts a `&String` into a `String` by cloning. * **Availability**: Available on non-`no_global_oom_handling` only. ### `impl From<&mut str> for String` #### `fn from(s: &mut str) -> String` * **Description**: Converts a mutable string slice `&mut str` into an owned `String`. The result is allocated on the heap. ### `impl From<&str> for String` #### `fn from(s: &str) -> String` * **Description**: Converts a string slice `&str` into an owned `String`. The result is allocated on the heap. ### `impl From for String` #### `fn from(value: AllowedOrigins) -> String` * **Description**: Converts an `AllowedOrigins` type into a `String`. ### `impl From> for String` #### `fn from(s: Box) -> String` * **Description**: Converts a boxed `str` slice (`Box`) into an owned `String`. The `str` slice is owned by the `Box`. * **Example**: ```rust let s1: String = String::from("hello world"); let s2: Box = s1.into_boxed_str(); let s3: String = String::from(s2); assert_eq!("hello world", s3) ``` ### `impl<'a> From> for String` #### `fn from(s: Cow<'a, str>) -> String` * **Description**: Converts a `Cow<'a, str>` (Clone-on-Write string) to an owned `String`. If the `Cow` is borrowed, it will allocate on the heap and copy the string. * **Availability**: Available on non-`no_global_oom_handling` only. * **Example**: ```rust // If the string is not owned... let cow: Cow<'_, str> = Cow::Borrowed("eggplant"); // It will allocate on the heap and copy the string. let owned: String = String::from(cow); assert_eq!(&owned[..], "eggplant"); ``` ### `impl From for String` #### `fn from(function_name: FunctionName) -> String` * **Description**: Converts a `FunctionName` type into a `String`. ### `impl From for String` #### `fn from(key: Key) -> String` * **Description**: Converts a `Key` type into a `String`. ### `impl From for String` #### `fn from(sb: SerializedBytesError) -> String` * **Description**: Converts a `SerializedBytesError` type into a `String`. ``` -------------------------------- ### Rust Result into_err() Example (Nightly) Source: https://docs.rs/holochain_client/latest/holochain_client/type.ConductorApiResult_search= An example of the experimental `into_err()` method (nightly-only), which returns the contained `Err` value without panicking. Similar to `into_ok()`, it serves as a compile-time safeguard. ```rust fn only_bad_news() -> Result { Err("Oops, it failed".into()) } let error: String = only_bad_news().into_err(); println!("{error}"); ``` -------------------------------- ### String Extension Source: https://docs.rs/holochain_client/latest/holochain_client/type.InstalledAppId_search=std%3A%3Avec Extends a String with characters, string slices, or boxed string slices. ```APIDOC ## POST /string/extend_chars ### Description Extends a String with the contents of an iterator of ASCII characters. ### Method POST ### Endpoint /string/extend_chars ### Parameters #### Request Body - **target_string** (String) - Required - The string to extend. - **chars_iterator** (Iterator) - Required - An iterator of ASCII characters to add. ### Response #### Success Response (200) - **updated_string** (String) - The extended string. #### Response Example ```json { "updated_string": "extended with chars" } ``` ## POST /string/extend_one_char ### Description Extends a String with exactly one ASCII character. ### Method POST ### Endpoint /string/extend_one_char ### Parameters #### Request Body - **target_string** (String) - Required - The string to extend. - **ascii_char** (&'a AsciiChar) - Required - The ASCII character to add. ### Response #### Success Response (200) - **updated_string** (String) - The extended string. #### Response Example ```json { "updated_string": "extended with one char" } ``` ## POST /string/extend_str ### Description Extends a String with the contents of an iterator of string slices. ### Method POST ### Endpoint /string/extend_str ### Parameters #### Request Body - **target_string** (String) - Required - The string to extend. - **str_slices_iterator** (Iterator) - Required - An iterator of string slices to add. ### Response #### Success Response (200) - **updated_string** (String) - The extended string. #### Response Example ```json { "updated_string": "extended with str slices" } ``` ## POST /string/extend_one_str ### Description Extends a String with exactly one string slice. ### Method POST ### Endpoint /string/extend_one_str ### Parameters #### Request Body - **target_string** (String) - Required - The string to extend. - **str_slice** (&'a str) - Required - The string slice to add. ### Response #### Success Response (200) - **updated_string** (String) - The extended string. #### Response Example ```json { "updated_string": "extended with one str slice" } ``` ## POST /string/extend_boxed_str ### Description Extends a String with the contents of an iterator of boxed string slices. ### Method POST ### Endpoint /string/extend_boxed_str ### Parameters #### Request Body - **target_string** (String) - Required - The string to extend. - **boxed_str_iterator** (Iterator>) - Required - An iterator of boxed string slices to add. ### Response #### Success Response (200) - **updated_string** (String) - The extended string. #### Response Example ```json { "updated_string": "extended with boxed str slices" } ``` ## POST /string/extend_one_boxed_str ### Description Extends a String with exactly one boxed string slice. ### Method POST ### Endpoint /string/extend_one_boxed_str ### Parameters #### Request Body - **target_string** (String) - Required - The string to extend. - **boxed_str** (Box) - Required - The boxed string slice to add. ### Response #### Success Response (200) - **updated_string** (String) - The extended string. #### Response Example ```json { "updated_string": "extended with one boxed str slice" } ``` ``` -------------------------------- ### EnableApp Functionality Source: https://docs.rs/holochain_client/latest/holochain_client/enum.AdminRequest_search= Enables a previously installed application identified by its `installed_app_id`. This makes the app's functionality available for use. Requires the application to have been previously installed. Returns `AdminResponse::AppEnabled`. ```rust AdminRequest::EnableApp { installed_app_id: String } ``` -------------------------------- ### TryFrom and TryInto Implementations Source: https://docs.rs/holochain_client/latest/holochain_client/struct.IssueAppAuthenticationTokenPayload_search= Provides functionality for attempting conversions between types, returning a `Result` to handle potential errors. ```APIDOC ## impl TryFrom for T and impl TryInto for T ### Description These implementations allow for fallible conversions between types. `TryFrom` enables converting a `U` into a `T`, while `TryInto` allows converting a `T` into a `U`, provided `U` implements `TryFrom`. ### Method * `try_from(value: U) -> Result>::Error>` (for `TryFrom`) * `try_into(self) -> Result>::Error>` (for `TryInto`) ### Parameters * **value** (U) - The value to attempt to convert from. * **self** (T) - The value to attempt to convert into. ### Response * **Result>::Error>** - A `Result` containing the converted value or an error if the conversion fails. * **Result>::Error>** - A `Result` containing the converted value or an error if the conversion fails. ### Error Handling * **Error Type**: `>::Error` or `>::Error` - The specific error type returned when a conversion fails. This is often `Infallible` if the conversion is guaranteed to succeed under certain conditions. ``` -------------------------------- ### Rust Result into_ok() Example (Nightly) Source: https://docs.rs/holochain_client/latest/holochain_client/type.ConductorApiResult_search= An example of the experimental `into_ok()` method (nightly-only), which returns the contained `Ok` value without panicking. It's intended as a compile-time safeguard against potential errors. ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ```