### Get Number of Methods Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to get the total number of methods available for the add-in. ```rust fn get_n_methods(&mut self) -> usize { ... } ``` -------------------------------- ### starts_with Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Checks if the slice starts with the given prefix. ```APIDOC ## starts_with ### Description Returns true if `needle` is a prefix of the slice or equal to the slice. ### Parameters - **needle** (&[T]) - Required - The prefix to check. ``` -------------------------------- ### Get Number of Properties Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to get the total number of properties available for the add-in. ```rust fn get_n_props(&mut self) -> usize { ... } ``` -------------------------------- ### starts_with Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CString1C.html Checks if the slice starts with the provided needle. ```APIDOC ## starts_with ### Description Returns `true` if `needle` is a prefix of the slice or equal to the slice. ### Parameters - **needle** (&[T]) - Required - The prefix to check for. ``` -------------------------------- ### GET /as_array Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Gets a reference to the underlying array. ```APIDOC ## GET /as_array ### Description Gets a reference to the underlying array. Returns None if the requested size N does not match the slice length. ### Method GET ### Endpoint /as_array ### Parameters #### Query Parameters - **N** (usize) - Required - The expected length of the array. ### Response #### Success Response (200) - **array** (Option<&[T; N]>) - The reference to the array if lengths match, otherwise None. ``` -------------------------------- ### GET /windows Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Returns an iterator over all contiguous windows of a specified length. ```APIDOC ## GET /windows ### Description Returns an iterator over all contiguous windows of length size. The windows overlap. Panics if size is zero. ### Method GET ### Endpoint /windows ### Parameters #### Query Parameters - **size** (usize) - Required - The length of each window. ### Response #### Success Response (200) - **iterator** (Windows<'_, T>) - An iterator over the slice windows. ``` -------------------------------- ### Get Add-in Info Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to retrieve add-in information. Returns a u16. Use version 2000; avoid version 1000 for static objects. ```rust fn get_info(&mut self) -> u16 { ... } ``` -------------------------------- ### Get Number of Parameters Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to get the number of parameters for a given method. ```rust fn get_n_params(&mut self, num: usize) -> usize { ... } ``` -------------------------------- ### GET /as_ptr Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Returns a raw pointer to the slice's buffer. ```APIDOC ## GET /as_ptr ### Description Returns a raw pointer to the slice's buffer. The caller must ensure the slice outlives the pointer and that the memory is not mutated while the pointer is in use. ### Method GET ### Endpoint /as_ptr ### Response #### Success Response (200) - **pointer** (*const T) - A raw pointer to the start of the slice buffer. ``` -------------------------------- ### pub fn as_array(&self) -> Option<&[T; N]> Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CString1C.html Gets a reference to the underlying array. ```APIDOC ## GET /slice/as_array ### Description Gets a reference to the underlying array. Returns None if the length of the slice does not match N. ### Method GET ### Endpoint as_array() ### Parameters #### Path Parameters - **N** (usize) - Required - The expected length of the array. ### Response - **array** (Option<&[T; N]>) - Reference to the array if lengths match, otherwise None. ``` -------------------------------- ### Check if Slice Starts With a Prefix Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Use `starts_with` to determine if a slice begins with a given sequence of elements. An empty prefix always returns `true`. ```rust let v = [10, 40, 30]; assert!(v.starts_with(&[10])); assert!(v.starts_with(&[10, 40])); assert!(v.starts_with(&v)); assert!(!v.starts_with(&[50])); assert!(!v.starts_with(&[10, 50])); ``` ```rust let v = &[10, 40, 30]; assert!(v.starts_with(&[])); let v: &[u8] = &[]; assert!(v.starts_with(&[])); ``` -------------------------------- ### Get Method Name Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to get the name of a method at a given index and alias. ```rust fn get_method_name( &mut self, num: usize, alias: usize, ) -> Option<&'static CStr1C> { ... } ``` -------------------------------- ### Getting a Raw Pointer to Slice Buffer Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Shows how to obtain a raw pointer to the beginning of a slice's buffer using `as_ptr`. The caller must ensure the slice outlives the pointer and that the memory is not mutated through this pointer. ```rust let x = &[1, 2, 4]; let x_ptr = x.as_ptr(); unsafe { for i in 0..x.len() { assert_eq!(x.get_unchecked(i), &*x_ptr.add(i)); } } ``` -------------------------------- ### GET /as_ptr_range Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Returns the two raw pointers spanning the slice. ```APIDOC ## GET /as_ptr_range ### Description Returns the two raw pointers spanning the slice. The returned range is half-open, where the end pointer points one past the last element. ### Method GET ### Endpoint /as_ptr_range ### Response #### Success Response (200) - **range** (Range<*const T>) - A range containing the start and end pointers of the slice. ``` -------------------------------- ### Iterate Over Ok Value Source: https://docs.rs/addin1c/0.7.0/addin1c/type.AddinResult.html Use iter to get an iterator that yields a reference to the Ok value if present, otherwise yields nothing. The iterator yields at most one item. ```rust let x: Result = Ok(7); assert_eq!(x.iter().next(), Some(&7)); ``` ```rust let x: Result = Err("nothing!"); assert_eq!(x.iter().next(), None); ``` -------------------------------- ### Finding Range of Matching Items with partition_point Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Use `partition_point` to find the range of elements that satisfy a condition. This is useful for finding all occurrences of a specific value in a sorted slice. The first call finds the start of the range, and the second finds the end. ```rust let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]; let low = s.partition_point(|x| x < &1); assert_eq!(low, 1); let high = s.partition_point(|x| x <= &1); assert_eq!(high, 5); let r = s.binary_search(&1); assert!((low..high).contains(&r.unwrap())); assert!(s[..low].iter().all(|&x| x < 1)); assert!(s[low..high].iter().all(|&x| x == 1)); assert!(s[high..].iter().all(|&x| x > 1)); // For something not found, the "range" of equal items is empty assert_eq!(s.partition_point(|x| x < &11), 9); assert_eq!(s.partition_point(|x| x <= &11), 9); assert_eq!(s.binary_search(&11), Err(9)); ``` -------------------------------- ### Remove Prefix from Slice Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Use `strip_prefix` to get a subslice with the specified prefix removed. Returns `None` if the slice does not start with the prefix. An empty prefix results in the original slice. ```rust let slice = &[1, 2, 3, 4, 5]; let prefix = &[1, 2]; let suffix = slice.strip_prefix(prefix); assert_eq!(suffix, Some(&[3, 4, 5][..])); let empty_prefix_slice = &[1, 2, 3]; assert_eq!(empty_prefix_slice.strip_prefix(&[]), Some(&[1, 2, 3][..])); let full_prefix_slice = &[1, 2, 3]; assert_eq!(full_prefix_slice.strip_prefix(&[1, 2, 3]), Some(&[][..])); let no_match_slice = &[1, 2, 3]; assert_eq!(no_match_slice.strip_prefix(&[4]), None); ``` -------------------------------- ### Initialize Add-in Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method for initializing the add-in. It takes a static connection reference and returns a boolean indicating success. ```rust fn init(&mut self, interface: &'static Connection) -> bool { ... } ``` -------------------------------- ### Initialize an add-in component Source: https://docs.rs/addin1c/0.7.0/addin1c/fn.create_component.html This function is unsafe and requires the component pointer to be non-null. ```rust pub unsafe fn create_component( component: *mut *mut c_void, addin: T, ) -> c_long ``` -------------------------------- ### Convert Result to Option (Ok value) Source: https://docs.rs/addin1c/0.7.0/addin1c/type.AddinResult.html Explains how to use the `ok` method to convert a Result into an Option, retaining the success value. ```rust let x: Result = Ok(2); assert_eq!(x.ok(), Some(2)); let x: Result = Err("Nothing here"); assert_eq!(x.ok(), None); ``` -------------------------------- ### pub fn windows(&self, size: usize) -> Windows<'_, T> Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CString1C.html Returns an iterator over all contiguous windows of length size. ```APIDOC ## GET /slice/windows ### Description Returns an iterator over all contiguous windows of length size. The windows overlap. ### Method GET ### Endpoint windows(size) ### Parameters #### Query Parameters - **size** (usize) - Required - The length of each window. ### Response - **iterator** (Windows<'_, T>) - An iterator over overlapping windows. ``` -------------------------------- ### Get Property Name Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to get the name of a property at a given index and alias. ```rust fn get_prop_name( &mut self, num: usize, alias: usize, ) -> Option<&'static CStr1C> { ... } ``` -------------------------------- ### Done Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method called when the add-in is done. ```rust fn done(&mut self) { ... } ``` -------------------------------- ### into_ok Source: https://docs.rs/addin1c/0.7.0/addin1c/type.AddinResult.html Returns the contained `Ok` value, but never panics. This is an experimental API and is nightly-only. ```APIDOC ## pub const fn into_ok(self) -> T ### Description Returns the contained `Ok` value, but never panics. Unlike `unwrap`, this method is known to never panic on the result types it is implemented for. Therefore, it can be used instead of `unwrap` as a maintainability safeguard that will fail to compile if the error type of the `Result` is later changed to an error that can actually occur. ### Method `into_ok` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (T) - The contained `Ok` value. #### Response Example ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` ### Note This is a nightly-only experimental API. ``` -------------------------------- ### Get Parameter Default Value Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to get the default value of a parameter for a specific method. ```rust fn get_param_def_value( &mut self, method_num: usize, param_num: usize, value: Variant<'_>, ) -> bool { ... } ``` -------------------------------- ### Get Mutable Reference to Result Content Source: https://docs.rs/addin1c/0.7.0/addin1c/type.AddinResult.html Illustrates using `as_mut` to get mutable references to the contained Ok or Err values. ```rust fn mutate(r: &mut Result) { match r.as_mut() { Ok(v) => *v = 42, Err(e) => *e = 0, } } let mut x: Result = Ok(2); mutate(&mut x); assert_eq!(x.unwrap(), 42); let mut x: Result = Err(13); mutate(&mut x); assert_eq!(x.unwrap_err(), 0); ``` -------------------------------- ### Get Property Value Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to get the value of a property at a given index. The value is returned via a mutable Variant reference. ```rust fn get_prop_val(&mut self, num: usize, val: &mut Variant<'_>) -> bool { ... } ``` -------------------------------- ### Getting Raw Pointers Spanning the Slice Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Illustrates using `as_ptr_range` to get a range of two raw pointers that span the slice. The end pointer is one past the last element. Useful for C-style interfaces. ```rust let a = [1, 2, 3]; let x = &a[1] as *const _; let y = &5 as *const _; assert!(a.as_ptr_range().contains(&x)); assert!(!a.as_ptr_range().contains(&y)); ``` -------------------------------- ### Result Implementations for AddinResult Source: https://docs.rs/addin1c/0.7.0/addin1c/type.AddinResult.html Provides documentation for common Result methods as they apply to AddinResult, including is_ok, is_err, ok, err, as_ref, as_mut, and map. ```APIDOC ## Implementations ### impl Result #### pub const fn is_ok(&self) -> bool Returns `true` if the result is `Ok`. ##### Examples ```rust let x: Result = Ok(-3); assert_eq!(x.is_ok(), true); let x: Result = Err("Some error message"); assert_eq!(x.is_ok(), false); ``` #### pub fn is_ok_and(self, f: F) -> bool where F: FnOnce(T) -> bool, Returns `true` if the result is `Ok` and the value inside of it matches a predicate. ##### Examples ```rust let x: Result = Ok(2); assert_eq!(x.is_ok_and(|x| x > 1), true); let x: Result = Ok(0); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Err("hey"); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Ok("ownership".to_string()); assert_eq!(x.as_ref().is_ok_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` #### pub const fn is_err(&self) -> bool Returns `true` if the result is `Err`. ##### Examples ```rust let x: Result = Ok(-3); assert_eq!(x.is_err(), false); let x: Result = Err("Some error message"); assert_eq!(x.is_err(), true); ``` #### pub fn is_err_and(self, f: F) -> bool where F: FnOnce(E) -> bool, Returns `true` if the result is `Err` and the value inside of it matches a predicate. ##### Examples ```rust use std::io::{Error, ErrorKind}; let x: Result = Err(Error::new(ErrorKind::NotFound, "!")); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), true); let x: Result = Err(Error::new(ErrorKind::PermissionDenied, "!")); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false); let x: Result = Ok(123); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false); let x: Result = Err("ownership".to_string()); assert_eq!(x.as_ref().is_err_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` #### pub fn ok(self) -> Option Converts from `Result` to `Option`. Converts `self` into an `Option`, consuming `self`, and discarding the error, if any. ##### Examples ```rust let x: Result = Ok(2); assert_eq!(x.ok(), Some(2)); let x: Result = Err("Nothing here"); assert_eq!(x.ok(), None); ``` #### pub fn err(self) -> Option Converts from `Result` to `Option`. Converts `self` into an `Option`, consuming `self`, and discarding the success value, if any. ##### Examples ```rust let x: Result = Ok(2); assert_eq!(x.err(), None); let x: Result = Err("Nothing here"); assert_eq!(x.err(), Some("Nothing here")); ``` #### pub const fn as_ref(&self) -> Result<&T, &E> Converts from `&Result` to `Result<&T, &E>`. Produces a new `Result`, containing a reference into the original, leaving the original in place. ##### Examples ```rust let x: Result = Ok(2); assert_eq!(x.as_ref(), Ok(&2)); let x: Result = Err("Error"); assert_eq!(x.as_ref(), Err(&"Error")); ``` #### pub const fn as_mut(&mut self) -> Result<&mut T, &mut E> Converts from `&mut Result` to `Result<&mut T, &mut E>`. ##### Examples ```rust fn mutate(r: &mut Result) { match r.as_mut() { Ok(v) => *v = 42, Err(e) => *e = 0, } } let mut x: Result = Ok(2); mutate(&mut x); assert_eq!(x.unwrap(), 42); let mut x: Result = Err(13); mutate(&mut x); assert_eq!(x.unwrap_err(), 0); ``` #### pub fn map(self, op: F) -> Result where F: FnOnce(T) -> U, Maps a `Result` to `Result` by applying a function to a contained `Ok` value, leaving an `Err` value untouched. This function can be used to compose the results of two functions. ##### Examples Print the numbers on each line of a string multiplied by two. ```rust let line = "1\n2\n3\n4\n"; for num in line.lines() { match num.parse::().map(|i| i * 2) { Ok(n) => println!("{{n}}"), Err(..) => {{}} } } ``` ``` -------------------------------- ### GET /chunks Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Returns an iterator over chunks of the slice. ```APIDOC ## GET /chunks ### Description Returns an iterator over chunk_size elements of the slice at a time. The chunks are non-overlapping. Panics if chunk_size is zero. ### Method GET ### Endpoint /chunks ### Parameters #### Query Parameters - **chunk_size** (usize) - Required - The size of each chunk. ### Response #### Success Response (200) - **iterator** (Chunks<'_, T>) - An iterator over the slice chunks. ``` -------------------------------- ### create_component Function Source: https://docs.rs/addin1c/0.7.0/addin1c/fn.create_component.html This function creates a new component and associates it with an addin. It requires the component pointer and the addin instance. ```APIDOC ## create_component ### Description Creates a new component and associates it with an addin. ### Method `pub unsafe fn create_component` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **component** (*mut *mut c_void) - Required - A mutable pointer to a pointer that will hold the created component. - **addin** (T: Addin) - Required - The addin instance to associate with the component. ### Request Example ```json { "component": "pointer_to_component_ptr", "addin": "addin_instance" } ``` ### Response #### Success Response (200) - **return_value** (c_long) - The result of the operation, typically 0 for success. #### Response Example ```json { "return_value": 0 } ``` ### Safety Component must be non-null. ``` -------------------------------- ### Call As Procedure Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to call a method as a procedure. It takes the method number and a slice of variants as parameters. ```rust fn call_as_proc( &mut self, method_num: usize, params: &mut [Variant<'_>], ) -> bool { ... } ``` -------------------------------- ### Register Extension Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Required method for registering the add-in extension. It returns a CStr1C representing the extension name. ```rust fn register_extension_as(&mut self) -> &CStr1C; ``` -------------------------------- ### rchunks Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CString1C.html Returns an iterator over chunk_size elements of the slice at a time, starting at the end of the slice. ```APIDOC ## rchunks ### Description Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end of the slice. The chunks are slices and do not overlap. ### Parameters #### Query Parameters - **chunk_size** (usize) - Required - The size of each chunk. ### Panics Panics if `chunk_size` is zero. ``` -------------------------------- ### PropInfo Blanket Implementations Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.PropInfo.html Details blanket implementations provided for the PropInfo struct. ```APIDOC ## Blanket Implementations for PropInfo ### `impl Any for T` - `fn type_id(&self) -> TypeId`: Gets the `TypeId` of `self`. ### `impl Borrow for T` - `fn borrow(&self) -> &T`: Immutably borrows from an owned value. ### `impl BorrowMut for T` - `fn borrow_mut(&mut self) -> &mut T`: Mutably borrows from an owned value. ### `impl From for T` - `fn from(t: T) -> T`: Returns the argument unchanged. ### `impl Into for T` - `fn into(self) -> U`: Calls `U::from(self)`. ### `impl TryFrom for T` - `type Error = Infallible` - `fn try_from(value: U) -> Result>::Error>`: Performs the conversion. ### `impl TryInto for T` - `type Error = >::Error` - `fn try_into(self) -> Result>::Error>`: Performs the conversion. ``` -------------------------------- ### rsplit Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Returns an iterator over subslices separated by elements that match a predicate, starting from the end. ```APIDOC ## rsplit ### Description Returns an iterator over subslices separated by elements that match the predicate, starting at the end of the slice and working backwards. The matched element is not contained in the subslices. ### Parameters #### Path Parameters - **pred** (F: FnMut(&T) -> bool) - Required - The predicate function used to identify split points. ### Response - **RSplit<'_, T, F>** - An iterator over the resulting subslices. ``` -------------------------------- ### rchunks_exact Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CString1C.html Returns an iterator over chunk_size elements of the slice at a time, starting at the end of the slice, omitting the remainder. ```APIDOC ## rchunks_exact ### Description Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end of the slice. If `chunk_size` does not divide the length of the slice, the remainder is omitted. ### Parameters #### Query Parameters - **chunk_size** (usize) - Required - The size of each chunk. ### Panics Panics if `chunk_size` is zero. ``` -------------------------------- ### Creating Contiguous Windows of Slice Elements Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Shows how to use the `windows` method to create an iterator over overlapping sub-slices (windows) of a specified size. Panics if the size is zero. ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let mut iter = slice.windows(3); assert_eq!(iter.next().unwrap(), &['l', 'o', 'r']); assert_eq!(iter.next().unwrap(), &['o', 'r', 'e']); assert_eq!(iter.next().unwrap(), &['r', 'e', 'm']); assert!(iter.next().is_none()); ``` ```rust let slice = ['f', 'o', 'o']; let mut iter = slice.windows(4); assert!(iter.next().is_none()); ``` ```rust use std::cell::Cell; let mut array = ['R', 'u', 's', 't', ' ', '2', '0', '1', '5']; let slice = &mut array[..]; let slice_of_cells: &[Cell] = Cell::from_mut(slice).as_slice_of_cells(); for w in slice_of_cells.windows(3) { Cell::swap(&w[0], &w[2]); } assert_eq!(array, ['s', 't', ' ', '2', '0', '1', '5', 'u', 'R']); ``` -------------------------------- ### element_offset Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Returns the index that an element reference points to. Returns None if element does not point to the start of an element within the slice. ```APIDOC ## element_offset(&self, element: &T) -> Option ### Description Returns the index that an element reference points to. Returns `None` if `element` does not point to the start of an element within the slice. This method is useful for extending slice iterators like `slice::split`. Note that this uses pointer arithmetic and **does not compare elements**. ### Method `element_offset` ### Parameters #### Path Parameters - `element` (&T) - Required - A reference to the element to find the offset for. ### Request Example ```rust #![feature(substr_range)] let nums: &[u32] = &[1, 7, 1, 1]; let num = &nums[2]; assert_eq!(nums.element_offset(num), Some(2)); ``` ### Response #### Success Response (Option) - Returns `Some(index)` if the element points to the start of an element within the slice, otherwise `None`. #### Response Example ```rust // For nums = &[1, 7, 1, 1] and num = &nums[2], returns Some(2). // For an unaligned element, returns None. ``` ``` -------------------------------- ### Connection Methods Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.Connection.html Methods available on the Connection struct for handling external events and buffer management. ```APIDOC ## Connection Methods ### external_event Sends an external event to the 1C:Enterprise platform. - **source** (impl AsRef) - Required - The source of the event. - **message** (impl AsRef) - Required - The event message. - **data** (impl AsRef) - Required - The event data. - **Returns** (bool) - Returns true if the event was successfully sent. ### set_event_buffer_depth Sets the depth of the event buffer. - **depth** (c_long) - Required - The new buffer depth. - **Returns** (bool) - Returns true if the operation was successful. ### get_event_buffer_depth Retrieves the current depth of the event buffer. - **Returns** (c_long) - The current buffer depth. ### clean_event_buffer Clears all events currently stored in the event buffer. ``` -------------------------------- ### Get Immutable Reference to Result Content Source: https://docs.rs/addin1c/0.7.0/addin1c/type.AddinResult.html Shows how to use `as_ref` to obtain references to the contained values without consuming the Result. ```rust let x: Result = Ok(2); assert_eq!(x.as_ref(), Ok(&2)); let x: Result = Err("Error"); assert_eq!(x.as_ref(), Err(&"Error")); ``` -------------------------------- ### Iterate over chunks from the end with rchunks Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Returns an iterator over chunks of size chunk_size starting from the end of the slice. Panics if chunk_size is zero. ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let mut iter = slice.rchunks(2); assert_eq!(iter.next().unwrap(), &['e', 'm']); assert_eq!(iter.next().unwrap(), &['o', 'r']); assert_eq!(iter.next().unwrap(), &['l']); assert!(iter.next().is_none()); ``` -------------------------------- ### String Macros Source: https://docs.rs/addin1c Macros for handling UTF-16 string conversions required by the 1C:Enterprise platform. ```APIDOC ## Macros - **cstr1c**: Null terminated utf-16 static string, used for names. - **name**: Null terminated utf-16 static string, used for names. - **str1c**: Non null utf-16 static string, used for 1c-strings. - **utf16**: Turns a string literal into a `u16` array literal (`[u16; N]`). - **utf16_null**: Turns a string literal into a `u16` array literal (`[u16; N]`) with a trailing `0`. ``` -------------------------------- ### rsplit Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CString1C.html Returns an iterator over subslices separated by elements that match a given predicate, starting from the end of the slice. The matched element is not included in the subslices. ```APIDOC ## pub fn rsplit(&self, pred: F) -> RSplit<'_, T, F> where F: FnMut(&T) -> bool ### Description Returns an iterator over subslices separated by elements that match `pred`, starting at the end of the slice and working backwards. The matched element is not contained in the subslices. ### Method `fn` ### Endpoint N/A (Method on slice type) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters for `pred` closure - **`&T`**: A reference to an element of the slice. ### Returns - `RSplit<'_, T, F>`: An iterator over subslices. ### Examples ```rust let slice = [11, 22, 33, 0, 44, 55]; let mut iter = slice.rsplit(|num| *num == 0); assert_eq!(iter.next().unwrap(), &[44, 55]); assert_eq!(iter.next().unwrap(), &[11, 22, 33]); assert_eq!(iter.next(), None); ``` As with `split()`, if the first or last element is matched, an empty slice will be the first (or last) item returned by the iterator. ```rust let v = &[0, 1, 1, 2, 3, 5, 8]; let mut it = v.rsplit(|n| *n % 2 == 0); assert_eq!(it.next().unwrap(), &[]); assert_eq!(it.next().unwrap(), &[3, 5]); assert_eq!(it.next().unwrap(), &[1, 1]); assert_eq!(it.next().unwrap(), &[]); assert_eq!(it.next(), None); ``` ``` -------------------------------- ### rchunks_exact Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Returns an iterator over exact chunks of a specified size starting from the end of the slice. Any remaining elements are available via the `remainder` function. ```APIDOC ## pub fn rchunks_exact(&self, chunk_size: usize) -> RChunksExact<'_, T> ### Description Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end of the slice. The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the slice, then the last up to `chunk_size-1` elements will be omitted and can be retrieved from the `remainder` function of the iterator. ### Method GET (conceptual, as it returns an iterator) ### Endpoint N/A (method on slice) ### Parameters #### Path Parameters None #### Query Parameters - **chunk_size** (usize) - Required - The exact desired size of each chunk. #### Request Body None ### Request Example ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let mut iter = slice.rchunks_exact(2); assert_eq!(iter.next().unwrap(), &['e', 'm']); assert_eq!(iter.next().unwrap(), &['o', 'r']); assert!(iter.next().is_none()); assert_eq!(iter.remainder(), &['l']); ``` ### Response #### Success Response (200) An iterator yielding slices of exactly `chunk_size` elements from the end, and a `remainder` method to access leftover elements. #### Response Example ```rust // Example output from iterator: // &['e', 'm'] // &['o', 'r'] // Remainder: &['l'] ``` ##### §Panics Panics if `chunk_size` is zero. ``` -------------------------------- ### Provide default with unwrap_or Source: https://docs.rs/addin1c/0.7.0/addin1c/type.AddinResult.html Returns the contained Ok value or a provided default value. Arguments are eagerly evaluated. ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` -------------------------------- ### rchunks Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Returns an iterator over chunks of a specified size starting from the end of the slice. The last chunk may be smaller if the size does not divide the length. ```APIDOC ## pub fn rchunks(&self, chunk_size: usize) -> RChunks<'_, T> ### Description Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end of the slice. The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the slice, then the last chunk will not have length `chunk_size`. ### Method GET (conceptual, as it returns an iterator) ### Endpoint N/A (method on slice) ### Parameters #### Path Parameters None #### Query Parameters - **chunk_size** (usize) - Required - The desired size of each chunk. #### Request Body None ### Request Example ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let mut iter = slice.rchunks(2); assert_eq!(iter.next().unwrap(), &['e', 'm']); assert_eq!(iter.next().unwrap(), &['o', 'r']); assert_eq!(iter.next().unwrap(), &['l']); assert!(iter.next().is_none()); ``` ### Response #### Success Response (200) An iterator yielding slices representing the chunks from the end. #### Response Example ```rust // Example output from iterator: // &['e', 'm'] // &['o', 'r'] // &['l'] ``` ##### §Panics Panics if `chunk_size` is zero. ``` -------------------------------- ### pub fn connect Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CString1C.html Deprecated method for joining elements, renamed to join. ```APIDOC ## pub fn connect ### Description Flattens a slice of `T` into a single value `Self::Output`, placing a given separator between each. Deprecated since 1.3.0: renamed to join. ### Parameters #### Arguments - **sep** (Separator) - The separator to place between elements. ### Request Example ```rust assert_eq!(["hello", "world"].connect(" "), "hello world"); ``` ``` -------------------------------- ### Calculate Product of Result Iterator Source: https://docs.rs/addin1c/0.7.0/addin1c/type.AddinResult.html Demonstrates using the product method on an iterator of Results, which short-circuits on the first Err encountered. ```rust let nums = vec!["5", "10", "1", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert_eq!(total, Ok(100)); let nums = vec!["5", "10", "one", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert!(total.is_err()); ``` -------------------------------- ### Debug Implementation for AttachType Source: https://docs.rs/addin1c/0.7.0/addin1c/enum.AttachType.html Provides a way to format the AttachType enum for debugging purposes. This implementation is automatically derived and requires no specific setup. ```rust impl Debug for AttachType ``` -------------------------------- ### Split slice into chunks with as_chunks Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CString1C.html Partitions a slice into fixed-size arrays and a remainder slice, panicking if the chunk size is zero. ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let (chunks, remainder) = slice.as_chunks(); assert_eq!(chunks, &[['l', 'o'], ['r', 'e']]); assert_eq!(remainder, &['m']); ``` ```rust let slice = ['R', 'u', 's', 't']; let (chunks, []) = slice.as_chunks::<2>() else { panic!("slice didn't have even length") }; assert_eq!(chunks, &[['R', 'u'], ['s', 't']]); ``` -------------------------------- ### Set Locale Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to set the locale for the add-in. ```rust fn set_locale(&mut self, loc: &[u16]) { ... } ``` -------------------------------- ### as_rchunks Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Splits a slice into a slice of N-element arrays starting from the end, and a remainder slice. The remainder contains elements at the beginning that do not form a full chunk. ```APIDOC ## as_rchunks ### Description Splits the slice into a slice of `N`-element arrays, starting at the end of the slice, and a remainder slice with length strictly less than `N`. The remainder is meaningful in the division sense. ### Method as_rchunks(&self) -> (&[T], &[[T; N]]) ### Parameters #### Path Parameters - **N** (const usize) - Required - The size of each array chunk. ### Panics Panics if `N` is zero. ### Response #### Success Response (Tuple of Slices) - Returns a tuple containing: - A slice containing the remaining elements at the beginning (`remainder`). - A slice of `N`-element arrays from the end (`chunks`). ### Request Example ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let (remainder, chunks) = slice.as_rchunks::<2>(); assert_eq!(remainder, &['l']); assert_eq!(chunks, &[['o', 'r'], ['e', 'm']]); ``` ``` -------------------------------- ### Strip Prefix from Slice Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Use `strip_prefix` to remove a prefix from a slice. Returns `None` if the slice does not start with the specified prefix. Works with byte slices as well. ```rust let v = &[10, 40, 30]; assert_eq!(v.strip_prefix(&[10]), Some(&[40, 30][..])); assert_eq!(v.strip_prefix(&[10, 40]), Some(&[30][..])); assert_eq!(v.strip_prefix(&[10, 40, 30]), Some(&[][..])); assert_eq!(v.strip_prefix(&[50]), None); assert_eq!(v.strip_prefix(&[10, 50]), None); ``` ```rust let prefix : &str = "he"; assert_eq!(b"hello".strip_prefix(prefix.as_bytes()), Some(b"llo".as_ref())); ``` -------------------------------- ### Set User Interface Language Code Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to set the user interface language code for the add-in. ```rust fn set_user_interface_language_code(&mut self, lang: &[u16]) { ... } ``` -------------------------------- ### Iterate over exact chunks from the end with rchunks_exact Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Returns an iterator over chunks of exactly chunk_size starting from the end. Remaining elements can be accessed via the remainder method. ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let mut iter = slice.rchunks_exact(2); assert_eq!(iter.next().unwrap(), &['e', 'm']); assert_eq!(iter.next().unwrap(), &['o', 'r']); assert!(iter.next().is_none()); assert_eq!(iter.remainder(), &['l']); ``` -------------------------------- ### Call As Function Method Source: https://docs.rs/addin1c/0.7.0/addin1c/trait.RawAddin.html Provided method to call a method as a function. It takes the method number, parameters, and a mutable variant for the return value. ```rust fn call_as_func( &mut self, method_num: usize, params: &mut [Variant<'_>], val: &mut Variant<'_>, ) -> bool { ... } ``` -------------------------------- ### TryFrom Implementation for ParamValue Source: https://docs.rs/addin1c/0.7.0/addin1c/enum.ParamValue.html Demonstrates the TryFrom trait implementation for converting a value into a ParamValue. This allows for fallible conversions, returning a Result. ```rust type Error = Infallible fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### Check if Result is Ok and Matches Predicate Source: https://docs.rs/addin1c/0.7.0/addin1c/type.AddinResult.html Illustrates using `is_ok_and` to verify if a Result is Ok and its value satisfies a given condition. ```rust let x: Result = Ok(2); assert_eq!(x.is_ok_and(|x| x > 1), true); let x: Result = Ok(0); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Err("hey"); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Ok("ownership".to_string()); assert_eq!(x.as_ref().is_ok_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` -------------------------------- ### Strip Circumfix from Slice (Nightly) Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Use `strip_circumfix` to remove both a prefix and a suffix from a slice. This is an experimental API. Returns `None` if the slice does not start with the prefix or end with the suffix. ```rust #![feature(strip_circumfix)] let v = &[10, 50, 40, 30]; assert_eq!(v.strip_circumfix(&[10], &[30]), Some(&[50, 40][..])); assert_eq!(v.strip_circumfix(&[10], &[40, 30]), Some(&[50][..])); assert_eq!(v.strip_circumfix(&[10, 50], &[40, 30]), Some(&[][..])); assert_eq!(v.strip_circumfix(&[50], &[30]), None); assert_eq!(v.strip_circumfix(&[10], &[40]), None); assert_eq!(v.strip_circumfix(&[], &[40, 30]), Some(&[10, 50][..])); assert_eq!(v.strip_circumfix(&[10, 50], &[]), Some(&[40, 30][..])); ``` -------------------------------- ### Check if Result is Ok Source: https://docs.rs/addin1c/0.7.0/addin1c/type.AddinResult.html Demonstrates how to use the `is_ok` method to check if a Result contains a success value. ```rust let x: Result = Ok(-3); assert_eq!(x.is_ok(), true); let x: Result = Err("Some error message"); assert_eq!(x.is_ok(), false); ``` -------------------------------- ### Iterate over slice chunks with remainder Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CStr1C.html Use `chunks` to get an iterator over non-overlapping slices of a specified size. The last chunk may be smaller if the slice length is not a multiple of the chunk size. ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let mut iter = slice.chunks(2); assert_eq!(iter.next().unwrap(), &['l', 'o']); assert_eq!(iter.next().unwrap(), &['r', 'e']); assert_eq!(iter.next().unwrap(), &['m']); assert!(iter.next().is_none()); ``` -------------------------------- ### CString1C::new Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CString1C.html Constructs a new CString1C from a string slice. ```APIDOC ## CString1C::new ### Description Constructs a new CString1C from a string slice. ### Method `pub fn new(str: &str) -> Self` ### Parameters #### Path Parameters - **str** (string slice) - The string slice to convert into a CString1C. ### Response #### Success Response (Self) - Returns a new `Self` (CString1C) instance. ### Request Example ```rust let my_string = CString1C::new("Hello, 1C!"); ``` ``` -------------------------------- ### chunks_exact Source: https://docs.rs/addin1c/0.7.0/addin1c/struct.CString1C.html Returns an iterator over `chunk_size` elements of the slice at a time, starting at the beginning of the slice. The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the slice, then the last up to `chunk_size-1` elements will be omitted. ```APIDOC ## chunks_exact ### Description Returns an iterator over `chunk_size` elements of the slice at a time, starting at the beginning of the slice. The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the slice, then the last up to `chunk_size-1` elements will be omitted and can be retrieved from the `remainder` function of the iterator. ### Method `chunks_exact` ### Parameters #### Path Parameters - **chunk_size** (usize) - Required - The desired size of each chunk. ### Panics Panics if `chunk_size` is zero. ### Examples ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let mut iter = slice.chunks_exact(2); assert_eq!(iter.next().unwrap(), &['l', 'o']); assert_eq!(iter.next().unwrap(), &['r', 'e']); assert!(iter.next().is_none()); assert_eq!(iter.remainder(), &['m']); ``` ```