### Komodo Core API - Example Request (write::UpdateBuild) Source: https://docs.rs/komodo_client/latest/komodo_client/api/index Provides a cURL example for updating a build resource, demonstrating authentication and request body format. ```APIDOC ## POST /write - UpdateBuild Example ### Description Updates an existing build resource with new configuration details. ### Method `POST` ### Endpoint `/write` ### Headers * `Content-Type`: `application/json` * `X-Api-Key`: `your_api_key` * `X-Api-Secret`: `your_api_secret` ### Request Body ```json { "type": "UpdateBuild", "params": { "id": "67076689ed600cfdd52ac637", "config": { "version": "1.15.9" } } } ``` ### Request Example (cURL) ```bash curl --header "Content-Type: application/json" \ --header "X-Api-Key: your_api_key" \ --header "X-Api-Secret: your_api_secret" \ --data '{ "type": "UpdateBuild", "params": { "id": "67076689ed600cfdd52ac637", "config": { "version": "1.15.9" } } }' \ https://komodo.example.com/write ``` ``` -------------------------------- ### Start Stack (Docker Compose) Source: https://docs.rs/komodo_client/latest/komodo_client/api/execute/index Starts the target stack using the 'docker compose start' command. The response indicates an 'Update'. ```Shell docker compose start ``` -------------------------------- ### Start All Containers Source: https://docs.rs/komodo_client/latest/komodo_client/api/execute/index Starts all containers on the target server. This command initiates the operation and returns an 'Update' status. ```Komodo CLI StartAllContainers ``` -------------------------------- ### Start Container Source: https://docs.rs/komodo_client/latest/komodo_client/api/execute/index Starts a specific container on the target server. The operation results in an 'Update' response. ```Komodo CLI StartContainer ``` -------------------------------- ### Start Deployment Source: https://docs.rs/komodo_client/latest/komodo_client/api/execute/index Starts the container associated with a specific deployment on the target server. The command returns an 'Update' status. ```Komodo CLI StartDeployment ``` -------------------------------- ### Komodo Core API - Example Request (read::GetDeployment) Source: https://docs.rs/komodo_client/latest/komodo_client/api/index Demonstrates a request to retrieve deployment information. ```APIDOC ## POST /read - GetDeployment Example ### Description Retrieves details about a specific deployment. ### Method `POST` ### Endpoint `/read` ### Headers * `Content-Type`: `application/json` * `Authorization`: `your_jwt` ### Request Body ```json { "type": "GetDeployment", "params": { "deployment": "66113df3abe32960b87018dd" } } ``` ``` -------------------------------- ### Define GithubWebhookAppInstallationConfig Struct (Rust) Source: https://docs.rs/komodo_client/latest/komodo_client/entities/config/core/struct Defines the structure for GitHub Webhook app installation configuration, including the installation ID and namespace. This struct is part of the komodo_client library. ```Rust pub struct GithubWebhookAppInstallationConfig { pub id: i64, pub namespace: String, } ``` -------------------------------- ### Komodo API: GetDeployment Example (JSON) Source: https://docs.rs/komodo_client/latest/komodo_client/api/index Example JSON body for a read::GetDeployment API request. It specifies the request type and parameters, including the deployment ID. ```json { "type": "GetDeployment", "params": { "deployment": "66113df3abe32960b87018dd" } } ``` -------------------------------- ### ActionConfigBuilder: Set Run at Startup Source: https://docs.rs/komodo_client/latest/komodo_client/entities/action/struct Configures whether an action should automatically run when the system starts. This is a boolean flag. ```rust pub fn run_at_startup(&mut self, value: bool) -> &mut Self ``` -------------------------------- ### Komodo API: UpdateBuild Example (Curl) Source: https://docs.rs/komodo_client/latest/komodo_client/api/index Example curl command to update a build configuration using the write::UpdateBuild API endpoint. It includes necessary headers for authentication and content type, along with the JSON payload for the update. ```bash curl --header "Content-Type: application/json" \ --header "X-Api-Key: your_api_key" \ --header "X-Api-Secret: your_api_secret" \ --data '{ "type": "UpdateBuild", "params": { "id": "67076689ed600cfdd52ac637", "config": { "version": "1.15.9" } } }' \ https://komodo.example.com/write ``` -------------------------------- ### ExtractData for StartDeployment Source: https://docs.rs/komodo_client/latest/komodo_client/api/execute/enum Extracts data for starting a deployment. It takes an ExecutionVariant and returns a Result containing StartDeployment or an Error. ```rust fn extract_data( self, variant: &ExecutionVariant, ) -> Result ``` -------------------------------- ### ActionConfigBuilder: Set Schedule Source: https://docs.rs/komodo_client/latest/komodo_client/entities/action/struct Provides the schedule for the action. Supports both standard CRON expressions and natural language descriptions parsed by an English-to-CRON utility. Example CRON: "0 0 0 1,15 * ?". Example English: "at midnight on the 1st and 15th of the month". ```rust pub fn schedule(&mut self, value: String) -> &mut Self ``` -------------------------------- ### ActionConfigBuilder: Default Implementation Source: https://docs.rs/komodo_client/latest/komodo_client/entities/action/struct Returns the default configuration for an `ActionConfigBuilder`, providing a starting point for building new configurations. ```rust fn default() -> Self ``` -------------------------------- ### Rust Vec clone_from example Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Demonstrates how to use the clone_from method to overwrite the contents of one Vec with a clone of another, emphasizing efficient reallocation. ```rust let x = vec![5, 6, 7]; let mut y = vec![8, 9, 10]; let yp: *const i32 = y.as_ptr(); y.clone_from(&x); // The value is the same assert_eq!(x, y); // And no reallocation occurred assert_eq!(yp, y.as_ptr()); ``` -------------------------------- ### Resource Methods for StackConfig and StackInfo Source: https://docs.rs/komodo_client/latest/komodo_client/entities/resource/struct Provides methods for the `Resource` struct when specialized with `StackConfig` and `StackInfo`. These include functions to get the project name, compose file paths, check if a path is a compose file, and retrieve all file paths and dependencies. ```rust pub fn project_name(&self, fresh: bool) -> String pub fn compose_file_paths(&self) -> &[String] pub fn is_compose_file(&self, path: &str) -> bool pub fn all_file_paths(&self) -> Vec pub fn all_file_dependencies(&self) -> Vec ``` -------------------------------- ### ExtractData for StartAllContainers Source: https://docs.rs/komodo_client/latest/komodo_client/api/execute/enum Extracts data for starting all containers. It takes an ExecutionVariant and returns a Result containing StartAllContainers or an Error. ```rust fn extract_data( self, variant: &ExecutionVariant, ) -> Result ``` -------------------------------- ### ExtractData for StartStack Source: https://docs.rs/komodo_client/latest/komodo_client/api/execute/enum Extracts data for starting a stack. It takes an ExecutionVariant and returns a Result containing StartStack or an Error. ```rust fn extract_data(self, variant: &ExecutionVariant) -> Result ``` -------------------------------- ### Construct Vec from Raw Parts - ManualDrop Example Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Demonstrates how to safely construct a Vec from raw parts by manually dropping the original Vec to retain control over its allocation. It shows overwriting elements and then rebuilding the Vec. ```rust #![feature(box_vec_non_null)] use std::ptr::NonNull; use std::mem; let v = vec![1, 2, 3]; // Prevent running `v`'s destructor so we are in complete control // of the allocation. let mut v = mem::ManuallyDrop::new(v); // Pull out the various important pieces of information about `v` let p = unsafe { NonNull::new_unchecked(v.as_mut_ptr()) }; let len = v.len(); let cap = v.capacity(); unsafe { // Overwrite memory with 4, 5, 6 for i in 0..len { p.add(i).write(4 + i); } // Put everything back together into a Vec let rebuilt = Vec::from_parts(p, len, cap); assert_eq!(rebuilt, [4, 5, 6]); } ``` -------------------------------- ### ExtractData for StartContainer Source: https://docs.rs/komodo_client/latest/komodo_client/api/execute/enum Extracts data for starting a specific container. It takes an ExecutionVariant and returns a Result containing StartContainer or an Error. ```rust fn extract_data( self, variant: &ExecutionVariant, ) -> Result ``` -------------------------------- ### Get Vec Capacity (Rust) Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Illustrates how to retrieve the current capacity of a Vec, which is the total number of elements it can hold before needing to reallocate. Includes examples for standard Vec and zero-sized elements. ```rust let mut vec: Vec = Vec::with_capacity(10); vec.push(42); assert!(vec.capacity() >= 10); ``` ```rust #[derive(Clone)] struct ZeroSized; fn main() { assert_eq!(std::mem::size_of::(), 0); let v = vec![ZeroSized; 0]; assert_eq!(v.capacity(), usize::MAX); } ``` -------------------------------- ### PeekMut for Modifying Last Vec Element Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Provides an example of using the nightly-only `peek_mut` API to get a mutable reference to the last element of a Vec. It demonstrates checking for emptiness, pushing elements, and modifying the last element. ```rust #![feature(vec_peek_mut)] let mut vec = Vec::new(); assert!(vec.peek_mut().is_none()); vec.push(1); vec.push(5); vec.push(2); assert_eq!(vec.last(), Some(&2)); if let Some(mut val) = vec.peek_mut() { *val = 0; } assert_eq!(vec.last(), Some(&0)); ``` -------------------------------- ### Rust KomodoClient Initialization and Usage Source: https://docs.rs/komodo_client/latest/komodo_client/index Demonstrates how to initialize the KomodoClient from environment variables and use it to read deployments and execute builds. It requires the 'dotenvy' crate for loading environment variables. ```rust dotenvy::dotenv().ok(); let client = KomodoClient::new_from_env()?; // Get all the deployments let deployments = client.read(ListDeployments::default()).await?; println!("{deployments:#?}"); let update = client.execute(RunBuild { build: "test-build".to_string() }).await?; ``` -------------------------------- ### Implement From for ServerBuilderConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/builder/struct Provides a conversion from PartialServerBuilderConfig to ServerBuilderConfig, allowing for easy promotion of partial configurations. ```rust impl From for ServerBuilderConfig Source§ #### fn from(value: PartialServerBuilderConfig) -> ServerBuilderConfig Converts to this type from the input type. Source ``` -------------------------------- ### Rust Vec Iterator Example Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Demonstrates how to create a consuming iterator from a Vec using `into_iter()`. It shows how to extract elements one by one until the iterator is exhausted. ```rust let v = vec!["a".to_string(), "b".to_string()]; let mut v_iter = v.into_iter(); let first_element: Option = v_iter.next(); assert_eq!(first_element, Some("a".to_string())); assert_eq!(v_iter.next(), Some("b".to_string())); assert_eq!(v_iter.next(), None); ``` -------------------------------- ### Implement From for PartialServerBuilderConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/builder/struct Provides a conversion from ServerBuilderConfig to PartialServerBuilderConfig, enabling the creation of partial configurations from full ones. ```rust impl From for PartialServerBuilderConfig Source§ #### fn from(value: ServerBuilderConfig) -> PartialServerBuilderConfig Converts to this type from the input type. Source ``` -------------------------------- ### Rust Vec Hashing Example Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Compares the hash of a Vec with the hash of a slice containing the same elements. This showcases that the hashing mechanism for Vec is consistent with its slice representation. ```rust use std::hash::BuildHasher; let b = std::hash::RandomState::new(); let v: Vec = vec![0xa8, 0x3c, 0x09]; let s: &[u8] = &[0xa8, 0x3c, 0x09]; assert_eq!(b.hash_one(v), b.hash_one(s)); ``` -------------------------------- ### Implement Default for Version Source: https://docs.rs/komodo_client/latest/komodo_client/entities/struct Provides a default value for the `Version` struct. This is typically used to initialize a `Version` object to a known starting state. ```rust fn default() -> Version ``` -------------------------------- ### Clone Implementation for PartialServerConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/server/struct Provides implementations for cloning `PartialServerConfig`. Includes `clone` for creating a duplicate and `clone_from` for copy-assignment. ```Rust impl Clone for PartialServerConfig fn clone(&self) -> PartialServerConfig fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Combine Policies with AND Source: https://docs.rs/komodo_client/latest/komodo_client/entities/builder/struct Creates a new `Policy` that requires both the current policy (`self`) and another policy (`other`) to return `Action::Follow`. ```rust fn and(self, other: P) -> And where T: Policy, P: Policy, ``` -------------------------------- ### Rust HashMap: Get Disjoint Mutable References Source: https://docs.rs/komodo_client/latest/komodo_client/entities/docker/volume/type Demonstrates how to safely get mutable references to multiple, non-overlapping values in a HashMap using `get_disjoint_unchecked_mut`. This method is unsafe and requires the caller to ensure keys do not overlap. ```rust use std::collections::HashMap; let mut libraries = HashMap::new(); libraries.insert("Bodleian Library".to_string(), 1602); libraries.insert("Athenæum".to_string(), 1807); libraries.insert("Herzogin-Anna-Amalia-Bibliothek".to_string(), 1691); libraries.insert("Library of Congress".to_string(), 1800); // SAFETY: The keys do not overlap. let [Some(a), Some(b)] = (unsafe { libraries.get_disjoint_unchecked_mut([ "Athenæum", "Bodleian Library", ]) }) else { panic!() }; // SAFETY: The keys do not overlap. let got = unsafe { libraries.get_disjoint_unchecked_mut([ "Athenæum", "Library of Congress", ]) }; assert_eq!( got, [ Some(&mut 1807), Some(&mut 1800), ], ); // SAFETY: The keys do not overlap. let got = unsafe { libraries.get_disjoint_unchecked_mut([ "Athenæum", "New York Public Library", ]) }; // Missing keys result in None assert_eq!(got, [Some(&mut 1807), None]); ``` -------------------------------- ### Blanket Implementations for PartialServerConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/server/struct Showcases blanket implementations for `PartialServerConfig`, such as `Any` for type identification and `Borrow`/`BorrowMut` for referencing. ```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 Conv for T ``` -------------------------------- ### Get the Length of a HashMap using len in Rust Source: https://docs.rs/komodo_client/latest/komodo_client/entities/docker/volume/type This snippet demonstrates how to get the number of elements in a HashMap using `len`. It initializes a HashMap, asserts that its length is 0, inserts a key-value pair, and then asserts that its length is 1. ```Rust use std::collections::HashMap; let mut a = HashMap::new(); assert_eq!(a.len(), 0); a.insert(1, "a"); assert_eq!(a.len(), 1); ``` -------------------------------- ### Get mutable slice from vector in Rust Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Demonstrates how to get a mutable slice (`&mut [T]`) of the entire vector using `as_mut_slice`. This allows in-place modification of the vector's elements and is useful for operations like reading data into the vector from I/O. ```rust use std::io::{self, Read}; let mut buffer = vec![0; 3]; io::repeat(0b101).read_exact(buffer.as_mut_slice()).unwrap(); ``` -------------------------------- ### Implement Clone for PartialServerBuilderConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/builder/struct Provides the functionality to clone PartialServerBuilderConfig instances. It includes methods for creating a duplicate and copying from another instance. ```rust impl Clone for PartialServerBuilderConfig Source§ #### fn clone(&self) -> PartialServerBuilderConfig Returns a duplicate of the value. Read more 1.0.0 · Source§ #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. Read more Source ``` -------------------------------- ### Rust: Create Vec with Capacity and Custom Allocator Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Demonstrates creating a `Vec` with a specified initial capacity using a custom allocator. It shows how to push elements and observes reallocation behavior. ```rust #![feature(allocator_api)] use std::alloc::System; let mut vec = Vec::with_capacity_in(10, System); // The vector contains no items, even though it has capacity for more assert_eq!(vec.len(), 0); assert!(vec.capacity() >= 10); // These are all done without reallocating... for i in 0..10 { vec.push(i); } assert_eq!(vec.len(), 10); assert!(vec.capacity() >= 10); // ...but this may make the vector reallocate vec.push(11); assert_eq!(vec.len(), 11); assert!(vec.capacity() >= 11); // A vector of a zero-sized type will always over-allocate, since no // allocation is necessary let vec_units = Vec::<(), System>::with_capacity_in(10, System); assert_eq!(vec_units.capacity(), usize::MAX); ``` -------------------------------- ### Komodo Core API - Modules Source: https://docs.rs/komodo_client/latest/komodo_client/api/index Lists the available API modules and their general purpose. ```APIDOC ## Komodo Core API - Modules ### auth Requests relating to logging in / obtaining authentication tokens. ### user User self-management actions (manage API keys, etc.). ### read Read-only requests which retrieve data from Komodo. ### execute Run actions on Komodo resources, e.g., `execute::RunBuild`. ### write Requests which alter data, like create/update/delete resources. ### terminal Requests related to terminal interactions. ``` -------------------------------- ### HashMap - Get Mut Source: https://docs.rs/komodo_client/latest/komodo_client/entities/docker/volume/type Retrieves a mutable reference to the value associated with a given key. ```APIDOC ## GET /hashmap/get_mut ### Description Returns a mutable reference to the value corresponding to the key. The key may be any borrowed form of the map’s key type. ### Method GET ### Endpoint /hashmap/get_mut ### Parameters #### Query Parameters - **key** (Q) - Required - The key to look up. ### Response #### Success Response (200) - **Option<&mut V>** (Option<&mut V>) - A mutable reference to the value, if the key exists. #### Response Example ```json { "value": "mutable_reference_to_value" } ``` ``` -------------------------------- ### len - Get Map Size Source: https://docs.rs/komodo_client/latest/komodo_client/entities/docker/volume/type Returns the number of elements currently stored in the HashMap. ```APIDOC ## GET /len ### Description Returns the number of elements in the map. ### Method GET ### Endpoint /len ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **usize** - The number of elements in the map. #### Response Example ```rust // Example usage in code: use std::collections::HashMap; let mut a = HashMap::new(); assert_eq!(a.len(), 0); a.insert(1, "a"); assert_eq!(a.len(), 1); ``` ``` -------------------------------- ### From Implementations for PartialBuildConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/build/struct Provides conversion implementations for PartialBuildConfig, allowing it to be created from `BuildConfig` and `BuildConfigDiff`, and to be converted into `BuildConfig`. ```rust impl From for PartialBuildConfig Source fn from(value: BuildConfig) -> PartialBuildConfig Converts to this type from the input type. impl From for PartialBuildConfig Source fn from(value: BuildConfigDiff) -> PartialBuildConfig Converts to this type from the input type. impl From for BuildConfig Source fn from(value: PartialBuildConfig) -> BuildConfig Converts to this type from the input type. ``` -------------------------------- ### Get Vector Capacity Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Returns the total number of elements the vector can hold without reallocating. ```APIDOC ## pub const fn capacity(&self) -> usize ### Description Returns the total number of elements the vector can hold without reallocating. ### Method `pub const fn capacity` ### Endpoint N/A (This is a Rust function, not an HTTP endpoint) ### Parameters None ### Request Example ```rust let mut vec: Vec = Vec::with_capacity(10); vec.push(42); assert!(vec.capacity() >= 10); #[derive(Clone)] struct ZeroSized; fn main() { assert_eq!(std::mem::size_of::(), 0); let v = vec![ZeroSized; 0]; assert_eq!(v.capacity(), usize::MAX); } ``` ### Response #### Success Response - `usize`: The total capacity of the vector. ``` -------------------------------- ### From Conversions for PartialServerConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/server/struct Shows conversions between `PartialServerConfig` and other configuration-related types like `ServerConfig` and `ServerConfigDiff`. ```Rust impl From for ServerConfig fn from(value: PartialServerConfig) -> ServerConfig impl From for PartialServerConfig fn from(value: ServerConfig) -> PartialServerConfig impl From for PartialServerConfig fn from(value: ServerConfigDiff) -> PartialServerConfig ``` -------------------------------- ### HashMap entry Source: https://docs.rs/komodo_client/latest/komodo_client/entities/docker/volume/type Gets the given key’s corresponding entry in the map for in-place manipulation. ```APIDOC ## POST /websites/rs_komodo_client_komodo_client/entry ### Description Gets the given key’s corresponding entry in the map for in-place manipulation. Allows for efficient insertion, modification, or retrieval of values based on keys. ### Method POST ### Endpoint /websites/rs_komodo_client_komodo_client/entry ### Parameters #### Request Body - **key** (K) - Required - The key to find the entry for. - **operation** (string) - Required - The operation to perform on the entry. Can be 'and_modify', 'or_insert', etc. (Specific operations would need to be defined by the API implementation). - **value** (V) - Optional - The value to insert if the entry does not exist, used with 'or_insert'. ### Request Example ```json { "key": "a", "operation": "or_insert", "value": 1 } ``` ### Response #### Success Response (200) - **entry_state** (string) - Indicates the state of the entry (e.g., 'Occupied', 'Vacant'). - **value** (V) - The value associated with the key, if applicable. #### Response Example ```json { "entry_state": "Occupied", "value": 1 } ``` ``` -------------------------------- ### Implement Serialize for PartialServerBuilderConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/builder/struct Enables serialization of PartialServerBuilderConfig into various data formats using the Serde library. ```rust impl Serialize for PartialServerBuilderConfig Source§ #### fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where __S: Serializer, Serialize this value into the given Serde serializer. Read more Source ``` -------------------------------- ### Vec Construction (Allocator API) Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type API endpoints for constructing new Vec instances with specified allocators, including an experimental nightly-only API. ```APIDOC ## POST /vec/new_in ### Description Constructs a new, empty `Vec` using the provided allocator. The vector will not allocate until elements are pushed onto it. ### Method POST ### Endpoint /vec/new_in ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **allocator** (A) - Required - The allocator to use for the vector. ### Request Example ```json { "allocator": "System" } ``` ### Response #### Success Response (200) - **new_vec** (Vec) - A new, empty vector. #### Response Example ```json { "new_vec": [] } ``` ### Notes This is a nightly-only experimental API (`allocator_api`). ## POST /vec/with_capacity_in ### Description Constructs a new, empty `Vec` with at least the specified capacity using the provided allocator. The vector will be able to hold at least `capacity` elements without reallocating. ### Method POST ### Endpoint /vec/with_capacity_in ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **capacity** (usize) - Required - The minimum capacity for the new vector. - **allocator** (A) - Required - The allocator to use for the vector. ### Request Example ```json { "capacity": 10, "allocator": "System" } ``` ### Response #### Success Response (200) - **new_vec** (Vec) - A new vector with the specified capacity. #### Response Example ```json { "new_vec": [] } ``` ### Notes This is a nightly-only experimental API (`allocator_api`). ### Panics Panics if the new capacity exceeds `isize::MAX` bytes. ``` -------------------------------- ### Implement Default for DeploymentQuerySpecificsBuilder Source: https://docs.rs/komodo_client/latest/komodo_client/entities/deployment/struct This code shows the implementation of the `Default` trait for DeploymentQuerySpecificsBuilder, providing a way to create a builder with its default initial state. ```rust fn default() -> DeploymentQuerySpecificsBuilder ``` -------------------------------- ### Clone Implementation for PartialBuildConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/build/struct Provides implementations for cloning PartialBuildConfig, allowing for the creation of duplicate values. This includes `clone()` for a simple copy and `clone_from()` for copy-assignment. ```rust impl Clone for PartialBuildConfig Source fn clone(&self) -> PartialBuildConfig Returns a duplicate of the value. Read more fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. Read more ``` -------------------------------- ### Implement DeploymentQuerySpecificsBuilder Methods Source: https://docs.rs/komodo_client/latest/komodo_client/entities/deployment/struct This section outlines the public methods available on the DeploymentQuerySpecificsBuilder. These methods, such as `server_ids`, `build_ids`, and `update_available`, allow chaining to configure a DeploymentQuerySpecifics object. ```rust pub fn build(self) -> DeploymentQuerySpecifics ``` ```rust pub fn server_ids( self, server_ids: impl Into>, ) -> DeploymentQuerySpecificsBuilder ``` ```rust pub fn build_ids( self, build_ids: impl Into>, ) -> DeploymentQuerySpecificsBuilder ``` ```rust pub fn update_available( self, update_available: impl Into, ) -> DeploymentQuerySpecificsBuilder ``` -------------------------------- ### Combine Policies with OR Source: https://docs.rs/komodo_client/latest/komodo_client/entities/builder/struct Creates a new `Policy` that returns `Action::Follow` if either the current policy (`self`) or another policy (`other`) returns `Action::Follow`. ```rust fn or(self, other: P) -> Or where T: Policy, P: Policy, ``` -------------------------------- ### Get HashMap Hasher in Rust Source: https://docs.rs/komodo_client/latest/komodo_client/entities/docker/volume/type Demonstrates how to retrieve a reference to the `BuildHasher` used by a HashMap, allowing inspection or use with other collections. ```rust use std::collections::HashMap; use std::hash::RandomState; let hasher = RandomState::new(); let map: HashMap = HashMap::with_hasher(hasher); let hasher: &RandomState = map.hasher(); ``` -------------------------------- ### Get HashMap Capacity (Rust) Source: https://docs.rs/komodo_client/latest/komodo_client/entities/docker/volume/type Retrieves the current capacity of a HashMap, which is the minimum number of elements it can hold before needing to reallocate. ```Rust use std::collections::HashMap; let map: HashMap = HashMap::with_capacity(100); assert!(map.capacity() >= 100); ``` -------------------------------- ### Implement Default for PartialServerBuilderConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/builder/struct Provides a default value for PartialServerBuilderConfig, allowing instances to be created with default settings. ```rust impl Default for PartialServerBuilderConfig Source§ #### fn default() -> PartialServerBuilderConfig Returns the “default value” for a type. Read more Source ``` -------------------------------- ### Rust: Get TypeId Source: https://docs.rs/komodo_client/latest/komodo_client/api/execute/struct Retrieves the `TypeId` of a given object. This is a fundamental operation for runtime type identification. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Rust: Nightly-Only CloneToUninit Implementation Source: https://docs.rs/komodo_client/latest/komodo_client/entities/resource/struct Demonstrates the `unsafe fn clone_to_uninit` method, a nightly-only experimental API. It performs copy-assignment from `self` to a raw pointer destination (`*mut u8`), requiring careful usage due to its unsafety. ```rust impl CloneToUninit for T where T: Clone { unsafe fn clone_to_uninit(&self, dest: *mut u8) { // ... implementation details ... } } ``` -------------------------------- ### Get the number of elements in a Rust vector (len) Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Returns the number of elements currently in the vector, also known as its length. This is a constant time operation. ```rust let a = vec![1, 2, 3]; assert_eq!(a.len(), 3); ``` -------------------------------- ### Rust: Combine policies with AND logic Source: https://docs.rs/komodo_client/latest/komodo_client/entities/config/core/struct The `and` function creates a new `Policy` that requires both the original policy (`self`) and the provided `other` policy to return `Action::Follow` for the combined policy to also return `Action::Follow`. ```rust fn and(self, other: P) -> And where T: Policy, P: Policy, ``` -------------------------------- ### HasResponse Implementation for SignUpLocalUser Source: https://docs.rs/komodo_client/latest/komodo_client/api/auth/struct Defines the response and error types associated with SignUpLocalUser requests and provides methods to get request and response types. ```rust type Response = JwtResponse ``` ```rust type Error = Error ``` ```rust fn req_type() -> &'static str ``` ```rust fn res_type() -> &'static str ``` -------------------------------- ### Default Implementation for PartialServerConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/server/struct Provides a default value for `PartialServerConfig`, allowing instantiation without explicitly setting all optional fields. ```Rust impl Default for PartialServerConfig fn default() -> PartialServerConfig ``` -------------------------------- ### Create HashMap with Capacity (Rust) Source: https://docs.rs/komodo_client/latest/komodo_client/entities/docker/volume/type Shows how to initialize a HashMap with a specified initial capacity to potentially avoid reallocations. ```Rust use std::collections::HashMap; let mut map: HashMap<&str, i32> = HashMap::with_capacity(10); ``` -------------------------------- ### Implement Debug for PartialServerBuilderConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/builder/struct Enables the debugging display for PartialServerBuilderConfig, allowing it to be formatted for debugging purposes. ```rust impl Debug for PartialServerBuilderConfig Source§ #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. Read more Source ``` -------------------------------- ### Get mutable slice of spare capacity Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Returns the remaining spare capacity of the vector as a slice of `MaybeUninit`. This slice can be used to fill the vector with data before marking it as initialized using `set_len`. ```rust pub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit] // Example usage: // Allocate vector big enough for 10 elements. let mut v = Vec::with_capacity(10); // Fill in the first 3 elements. let uninit = v.spare_capacity_mut(); uninit[0].write(0); uninit[1].write(1); uninit[2].write(2); // Mark the first 3 elements of the vector as being initialized. unsafe { v.set_len(3); } assert_eq!(&v, &[0, 1, 2]); ``` -------------------------------- ### Implement build method for RepoQuerySpecificsBuilder Source: https://docs.rs/komodo_client/latest/komodo_client/entities/repo/struct Demonstrates the `build` method for RepoQuerySpecificsBuilder. This method consumes the builder and returns a RepoQuerySpecifics object, signifying the completion of the query specifics configuration. ```rust pub fn build(self) -> RepoQuerySpecifics ``` -------------------------------- ### From<&SpecificPermission> for &'static str Implementation (Rust) Source: https://docs.rs/komodo_client/latest/komodo_client/entities/permission/enum Implements the `From` trait to convert a reference to `SpecificPermission` into a static string slice. This provides a convenient way to get string representations of the permissions. ```Rust fn from(x: &'_ derivative_strum SpecificPermission) -> &'static str ``` -------------------------------- ### Komodo Core API - General Information Source: https://docs.rs/komodo_client/latest/komodo_client/api/index Details common HTTP parameters, headers, and the general structure for API requests. ```APIDOC ## Komodo Core API - General Information Komodo Core exposes an HTTP API using standard JSON serialization. ### Common HTTP Parameters * **Method**: `POST` * **Path**: Varies by module (e.g., `/auth`, `/user`, `/read`, `/write`, `/execute`) ### Common Headers * `Content-Type`: `application/json` * `Authorization`: `your_jwt` (Use either this or X-Api-Key/X-Api-Secret) * `X-Api-Key`: `your_api_key` (Use either this or Authorization) * `X-Api-Secret`: `your_api_secret` (Use either this or Authorization) ### Request Body Structure All requests require a JSON body specifying the request type (`type`) and its parameters (`params`). ```json { "type": "RequestType", "params": { ... } } ``` ### Authentication Requests can be authenticated using either the `Authorization` header with a JWT, or the `X-Api-Key` and `X-Api-Secret` headers. ``` -------------------------------- ### Append an element to the end (Rust Vec push) Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type A basic example of using the `push` method to add an element to the end of a `Vec`. This operation takes amortized O(1) time and may reallocate. ```rust let mut vec = vec![1, 2]; vec.push(3); assert_eq!(vec, [1, 2, 3]); ``` -------------------------------- ### Rust: Policy composition with PolicyExt Source: https://docs.rs/komodo_client/latest/komodo_client/api/auth/struct Provides methods to combine policies. `and` creates a new policy that requires both policies to return `Action::Follow`. `or` creates a new policy that returns `Action::Follow` if either policy returns `Action::Follow`. ```rust fn and(self, other: P) -> And where Self: Policy, P: Policy, ``` ```rust fn or(self, other: P) -> Or where Self: Policy, P: Policy, ``` -------------------------------- ### Rust HashMap: Get Mutable Reference to Value Source: https://docs.rs/komodo_client/latest/komodo_client/entities/docker/volume/type Shows how to obtain a mutable reference to a value associated with a key in a HashMap using `get_mut`. This allows in-place modification of the value if the key exists. ```rust use std::collections::HashMap; let mut map = HashMap::new(); map.insert(1, "a"); if let Some(x) = map.get_mut(&1) { *x = "b"; } assert_eq!(map[&1], "b"); ``` -------------------------------- ### Debug Implementation for SignUpLocalUser Source: https://docs.rs/komodo_client/latest/komodo_client/api/auth/struct Allows SignUpLocalUser instances to be formatted for debugging purposes. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### Get Value from HashMap in Rust Source: https://docs.rs/komodo_client/latest/komodo_client/entities/docker/volume/type Retrieves a reference to the value corresponding to a given key from a HashMap. The key can be borrowed, but its Hash and Eq implementations must match the HashMap's key type. ```rust use std::collections::HashMap; let mut map = HashMap::new(); map.insert(1, "a"); assert_eq!(map.get(&1), Some(&"a")); assert_eq!(map.get(&2), None); ``` -------------------------------- ### Implement Sink for Vec Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Enables a Vec to function as an asynchronous sink, allowing it to receive and store items of type T. It defines methods for polling readiness, starting to send, flushing, and closing the sink. ```rust impl Sink for Vec ``` -------------------------------- ### Resource Trait Implementations (Clone, Debug, Default) Source: https://docs.rs/komodo_client/latest/komodo_client/entities/resource/struct Documents the `Clone`, `Debug`, and `Default` trait implementations for the `Resource` struct. These traits enable cloning resources, debugging them with formatters, and creating default instances. ```rust impl Clone for Resource impl Debug for Resource impl Default for Resource ``` -------------------------------- ### Resource Conversions to RepoExecutionArgs Source: https://docs.rs/komodo_client/latest/komodo_client/entities/resource/struct Documents the `From` trait implementations for converting specific `Resource` types into `RepoExecutionArgs`. This includes conversions from `Build`, `Repo`, and `ResourceSync` resources. ```rust impl From<&Resource> for RepoExecutionArgs impl From<&Resource> for RepoExecutionArgs impl From<&Resource> for RepoExecutionArgs impl From<&Resource> for RepoExecutionArgs ``` -------------------------------- ### Rust Vec: Deallocating with Box::from_raw() Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Provides an example of manually deallocating a vector's backing memory using `Box::from_raw()`. This is demonstrated with `ManuallyDrop` to prevent double-freeing when managing memory explicitly. ```rust use std::mem::{ManuallyDrop, MaybeUninit}; let mut v = ManuallyDrop::new(vec![0, 1, 2]); let ptr = v.as_mut_ptr(); let capacity = v.capacity(); let slice_ptr: *mut [MaybeUninit] = std::ptr::slice_from_raw_parts_mut(ptr.cast(), capacity); drop(unsafe { Box::from_raw(slice_ptr) }); ``` -------------------------------- ### Rust Vec Allocation Behavior Example Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Demonstrates how to manage Vec capacity to avoid memory leaks when dealing with large, temporary allocations. It shows filtering items and using `shrink_to_fit` to release unused capacity. ```rust static LONG_LIVED: Mutex>> = Mutex::new(Vec::new()); for i in 0..10 { let big_temporary: Vec = (0..1024).collect(); // discard most items let mut result: Vec<_> = big_temporary.into_iter().filter(|i| i % 100 == 0).collect(); // without this a lot of unused capacity might be moved into the global result.shrink_to_fit(); LONG_LIVED.lock().unwrap().push(result); } ``` -------------------------------- ### Rust TagColor Default Implementation Source: https://docs.rs/komodo_client/latest/komodo_client/entities/tag/enum Implements the Default trait for the TagColor enum, allowing for a default value to be provided when an instance is created without explicit initialization. This ensures a predictable starting state. ```rust impl Default for TagColor { fn default() -> TagColor { // Implementation details omitted, but would return a default TagColor variant, e.g., TagColor::Slate unimplemented!() } } ``` -------------------------------- ### Serialize Implementation for PartialServerConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/server/struct Implements the `Serialize` trait from the Serde library for `PartialServerConfig`, enabling serialization into various data formats. ```Rust impl Serialize for PartialServerConfig fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where __S: Serializer ``` -------------------------------- ### Rust Vec: Using as_ptr() for read-only access Source: https://docs.rs/komodo_client/latest/komodo_client/api/read/type Demonstrates how to get a raw pointer to a vector's buffer using `as_ptr()` and safely iterate over its elements using unsafe Rust. This method is suitable for read-only operations. ```rust let x = vec![1, 2, 4]; let x_ptr = x.as_ptr(); unsafe { for i in 0..x.len() { assert_eq!(*x_ptr.add(i), 1 << i); } } ``` -------------------------------- ### Implement CloneToUninit for Generic Type T Source: https://docs.rs/komodo_client/latest/komodo_client/entities/procedure/struct Provides a nightly-only experimental implementation of CloneToUninit for types that implement Clone. The clone_to_uninit method performs copy-assignment to an uninitialized memory location. ```rust impl CloneToUninit for T where T: Clone, unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Parse String List (Rust) Source: https://docs.rs/komodo_client/latest/komodo_client/parsers/fn Parses a list of strings from a comment-separated and multiline string. It handles lines starting with '#' as comments and also supports comma-separated values within a line. The function returns a `Vec` containing the extracted file paths. ```Rust pub fn parse_string_list(source: impl AsRef) -> Vec ``` -------------------------------- ### Deserialize Implementation for PartialServerConfig Source: https://docs.rs/komodo_client/latest/komodo_client/entities/server/struct Implements `Deserialize` from the Serde library for `PartialServerConfig`, enabling deserialization from various data formats. ```Rust impl<'de> Deserialize<'de> for PartialServerConfig fn deserialize<__D>(__deserializer: __D) -> Result where __D: Deserializer<'de> ```