### Get HTTP Metrics Snapshot Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient_search=std%3A%3Avec This example shows how to obtain a snapshot of HTTP metrics for the client. It involves creating a client, performing some API calls (commented out), and then accessing the `http_metrics` to print statistics like total requests and successful responses. This requires the `anytype::prelude::*` import. ```rust use anytype::prelude::*; let client = AnytypeClient::new("my-app")?; // ... make some API calls ... let metrics = client.http_metrics(); println!("Total requests: {}", metrics.total_requests); println!("Successful: {}", metrics.successful_responses); ``` -------------------------------- ### Anytype Tags: List, Get, and Create Tag Examples (Rust) Source: https://docs.rs/anytype/latest/anytype/tags/index Demonstrates how to use the Anytype client to list all tags for a property, retrieve a specific tag by its ID, and create a new tag with a name and color. Requires the 'anytype' crate and its prelude. ```Rust use anytype::prelude::*; let space_id = "your_space_id"; let property_id = "property_id"; // List all tags for a property let tags = client.tags(space_id, property_id).list().await?; // Get a specific tag let tag = client.tag(space_id, property_id, "tag_id").get().await?; // Create a new tag let tag = client.new_tag(space_id, property_id) .name("Urgent") .color(Color::Red) .create().await?; ``` -------------------------------- ### AnytypeCache Example Usage Source: https://docs.rs/anytype/latest/anytype/cache/struct.AnytypeCache Demonstrates how to interact with the AnytypeCache, specifically showing examples of clearing cached data. The examples illustrate calling `clear_spaces` and `clear_properties` with different arguments. ```rust client.cache().clear_spaces(); client.cache().clear_properties(None); ``` -------------------------------- ### Get Keystore Instance (Rust) Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient_search=std%3A%3Avec Retrieves the configured KeyStore instance associated with the AnytypeClient. This allows direct interaction with the keystore for managing credentials. The example shows how to configure a file-based keystore. ```rust pub fn get_key_store(&self) -> &KeyStore ``` -------------------------------- ### List Chat Messages Example (Rust) Source: https://docs.rs/anytype/latest/anytype/chats/index Demonstrates how to list chat messages using the Anytype client. It shows how to specify a chat ID, limit the number of messages, and access pagination state and message content. This example requires the `anytype::prelude::*` import. ```rust use anytype::prelude::*; let chat_id = "chat_object_id"; let page = client .chats() .list_messages(chat_id) .limit(20) .list_page() .await?; println!("unread: {}", page.state.messages_unread); println!( "latest message: {}", page.messages .first() .map(|m| &m.content.text) .unwrap_or(&""".into()) ); ``` -------------------------------- ### Example: Create a New Property in Rust Source: https://docs.rs/anytype/latest/anytype/properties/struct.NewPropertyRequest Demonstrates how to use the `NewPropertyRequest` builder to create a new property. This example shows chaining methods like `new_property`, `key`, and `create` to configure and send the property creation request asynchronously. ```rust let prop = client .new_property("space_id", "Priority", PropertyFormat::Select) .key("priority") .create().await?; ``` -------------------------------- ### Example: Create a New Object (Rust) Source: https://docs.rs/anytype/latest/anytype/objects/struct.NewObjectRequest_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to use the `NewObjectRequest` builder pattern to create a new object. This example shows setting the object's name, body content, and description before asynchronously creating it. ```rust use anytype::prelude::*; let obj = client.new_object(&space_id, "page") .name("My Document") .body("# Hello World\n\nThis is my document.") .description("A sample document") .create().await?; ``` -------------------------------- ### Update Type Example Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient_search=u32+-%3E+bool An example demonstrating how to update a type's name and add a new text property. It first creates a type, then updates it with new details. ```rust let project = client.new_type(&space_id, "My Project") .key("my_project") .create().await?; // change name and add a text field "Location" let typ = client.update_type(&space_id, &project.id) .name("My New Project") .property("Location", "location", PropertyFormat::Text) .update().await?; ``` -------------------------------- ### Anytype Rust API Client Pattern Examples Source: https://docs.rs/anytype/latest/anytype/index_search= Illustrates common API interaction patterns using the Anytype Rust API Client, including getting/deleting single items, creating new entities, updating existing entities, and listing entities with filters and limits. These examples leverage the fluent builder pattern. ```rust use anytype::prelude::*; // Get/Delete single item: client.(ids...).get/delete() let obj = client.object("space_id", "obj_id").get().await?; client.object("space_id", "obj_id").delete().await?; // Create: client.new_(required_args).optional_args().create() let space = client.new_space("My Space") .description("Description") .create().await?; // Update: client.update_(ids...).fields().update() let space = client.update_space("space_id") .name("New Name") .update().await?; // List: client.(ids...).limit().filter().list() let objects = client.objects("space_id") .filter(Filter::type_in(vec!["page"])) .limit(50) .list().await?; ``` -------------------------------- ### Get Configured KeyStore Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns a reference to the configured KeyStore. This allows direct interaction with the keystore for managing credentials. ```rust pub fn get_key_store(&self) -> &KeyStore ``` ```rust use anytype::prelude::*; let mut config = ClientConfig::default().app_name("my-app"); config.keystore = Some("file".to_string()); let client = AnytypeClient::with_config(config)?; let keystore = client.get_key_store(); println!("keystore id: {}", keystore.id()); ``` -------------------------------- ### Example: Create a New Space with NewSpaceRequest in Rust Source: https://docs.rs/anytype/latest/anytype/spaces/struct.NewSpaceRequest Demonstrates how to use the NewSpaceRequest builder pattern to create a new space with a specified name and description. This example shows chaining methods like `description` and `create`. ```rust let space = client.new_space("My Workspace") .description("A place for my projects") .create().await?; ``` -------------------------------- ### Rust: Example Usage of PropertyRequest Source: https://docs.rs/anytype/latest/anytype/properties/struct.PropertyRequest_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides examples of how to use the `PropertyRequest` struct to interact with properties. It demonstrates both retrieving a property using `.get().await?` and deleting a property using `.delete().await?`. These operations require a client instance and property identifiers. ```rust // Get a property let prop = client.property("space_id", "property_id").get().await?; // Delete a property let deleted = client.property("space_id", "property_id").delete().await?; ``` -------------------------------- ### ObjectRequest Struct Definition and Usage Examples (Rust) Source: https://docs.rs/anytype/latest/anytype/objects/struct.ObjectRequest Defines the ObjectRequest struct used for building requests to get or delete single objects. Includes examples for both getting and deleting an object using the Anytype client. ```rust pub struct ObjectRequest { /* private fields */ } // Get an object let obj = client.object(&space_id, &obj_id).get().await?; // Delete an object let archived = client.object(&space_id, &obj.id).delete().await?; ``` -------------------------------- ### Create AnytypeClient with Default Configuration Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient_search=std%3A%3Avec This example shows the basic creation of an `AnytypeClient` using default settings. It requires an application name and returns a `Result` which may contain the client or an error. This requires the `anytype::prelude::*` import. ```rust use anytype::prelude::*; let client = AnytypeClient::new("my-app")?; ``` -------------------------------- ### KeyStore Initialization Source: https://docs.rs/anytype/latest/anytype/keystore/struct.KeyStore_search=u32+-%3E+bool Methods for initializing a new KeyStore instance. ```APIDOC ## KeyStore Initialization ### `new_default_store` Creates a new keystore with the default platform store. #### Method `pub fn new_default_store(service: impl Into) -> Result` ### `new` Creates a new keystore with a specified service name and keystore specification. #### Method `pub fn new(service: impl Into, keystore_spec: &str) -> Result` ``` -------------------------------- ### PropertyRequest Struct and Examples (Rust) Source: https://docs.rs/anytype/latest/anytype/properties/struct.PropertyRequest Defines the PropertyRequest struct used for building requests to get or delete properties. Includes examples for both operations and outlines the return types and potential errors. ```rust pub struct PropertyRequest { /* private fields */ } // Get a property let prop = client.property("space_id", "property_id").get().await?; // Delete a property let deleted = client.property("space_id", "property_id").delete().await?; ``` -------------------------------- ### Example: Listing Objects with ListObjectsRequest (Rust) Source: https://docs.rs/anytype/latest/anytype/objects/struct.ListObjectsRequest Demonstrates how to use the ListObjectsRequest builder to fetch a list of objects. It shows setting a limit and iterating through the results. ```rust let results = client.objects(&space_id) .limit(50) .list().await?; for obj in results.iter() { println!("{}", obj.name.as_deref().unwrap_or("(unnamed)")); } ``` -------------------------------- ### Create Anytype Client with File-Based Keystore Source: https://docs.rs/anytype/latest/anytype/client/struct.ClientConfig_search= Demonstrates how to create an Anytype client using a file-based keystore and default configuration. It initializes the client with a specified application name and sets the keystore to use a file. ```rust use anytype::prelude::*; // create api client with file-based keystore and default configuration let my_app = "my-app"; let mut config = ClientConfig::default().app_name(my_app); config.keystore = Some("file".to_string()); let client = AnytypeClient::with_config(config)?; ``` -------------------------------- ### Example Usage of ObjectRequest: Get and Delete Object Source: https://docs.rs/anytype/latest/anytype/objects/struct.ObjectRequest_search= Demonstrates how to use the ObjectRequest struct to first retrieve an object using the `get` method and then delete it using the `delete` method. These operations are asynchronous and return a Result. ```rust // Get an object let obj = client.object(&space_id, &obj_id).get().await?; // Delete an object let archived = client.object(&space_id, &obj.id).delete().await?; ``` -------------------------------- ### Create Anytype Client with File-Based Keystore Source: https://docs.rs/anytype/latest/anytype/client/struct.ClientConfig_search=std%3A%3Avec Demonstrates how to create an Anytype client using a file-based keystore and default configuration. It initializes the client with a specified application name and sets the keystore to use a file. ```rust use anytype::prelude::*; // create api client with file-based keystore and default configuration let my_app = "my-app"; let mut config = ClientConfig::default().app_name(my_app); config.keystore = Some("file".to_string()); let client = AnytypeClient::with_config(config)?; ``` -------------------------------- ### Execute Chat List Request and Get Page (Rust) Source: https://docs.rs/anytype/latest/anytype/chats/struct.ChatListMessagesRequest_search=std%3A%3Avec Provides an example of executing the `ChatListMessagesRequest` using the `list_page` method. It demonstrates how to retrieve a `ChatMessagesPage` containing messages and their unread count. ```rust use anytype::prelude::*; let page = client .chats() .list_messages("chat_object_id") .limit(25) .list_page() .await?; println!("messages: {}, unread: {}", page.messages.len(), page.state.messages_unread); ``` -------------------------------- ### Anytype Rust API Client Quick Start Source: https://docs.rs/anytype/latest/anytype/index_search= Demonstrates how to initialize the Anytype Rust API client, authenticate, list spaces, create an object, search with filters, and delete an object. It requires the `anytype` crate and its prelude. ```rust use anytype::prelude::*; // Initialize the client with file-based keystore. let mut config = ClientConfig::default().app_name("my-app"); config.keystore = Some("file".to_string()); let client = AnytypeClient::with_config(config)?; if !client.auth_status()?.http.is_authenticated() { println!("Not authenticated. Please log in."); } // List spaces let spaces: PagedResult = client.spaces().list().await?; for space in spaces.iter() { println!("{}", &space.name); } // Get the first space let space1 = spaces.iter().next().unwrap(); // Create an object let obj = client.new_object(&space1.id, "page") .name("My Document") .body("# Hello World") .create().await?; // Search, with filtering and sorting let results: PagedResult = client.search_in(&space1.id) .text("meeting notes") .types(["page", "note"]) .sort_desc("last_modified_date") .limit(10) .execute().await?; for doc in results.iter() { println!("{} {}", doc.get_property_date("last_modified_date").unwrap_or_default(), doc.name.as_deref().unwrap_or("(unnamed)")); } // delete object client.object(&space1.id, &obj.id).delete().await?; ``` -------------------------------- ### Example: Updating a Space Source: https://docs.rs/anytype/latest/anytype/spaces/struct.UpdateSpaceRequest Demonstrates how to use the UpdateSpaceRequest builder to update a space's name and description. It shows chaining methods and awaiting the final update. ```rust let space = client.update_space("space_id") .name("New Name") .description("Updated description") .update().await?; ``` -------------------------------- ### Rust: Get Metadata of Paths with and_then Source: https://docs.rs/anytype/latest/anytype/type.Result_search=std%3A%3Avec Illustrates using `and_then` to retrieve file metadata, specifically the modified time. This example shows how to handle potential errors during path metadata retrieval, such as non-existent paths. ```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); ``` -------------------------------- ### Create AnytypeClient from Reqwest ClientBuilder Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient_search=std%3A%3Avec This example shows how to initialize an `AnytypeClient` using a pre-configured `reqwest::ClientBuilder` and `ClientConfig`. This allows for advanced customization of the underlying HTTP client, such as setting timeouts or proxies. This requires the `anytype::prelude::*` import. ```rust use anytype::prelude::*; let config = ClientConfig::default().app_name("my-app"); let builder = reqwest::Client::builder().timeout(std::time::Duration::from_secs(10)); let client = AnytypeClient::with_client(builder, config)?; ``` -------------------------------- ### KeyStore Initialization Source: https://docs.rs/anytype/latest/anytype/keystore/struct.KeyStore_search=std%3A%3Avec Methods for creating a new KeyStore instance. ```APIDOC ## POST /keystore/new_default_store ### Description Creates a new KeyStore with default platform storage. ### Method POST ### Endpoint /keystore/new_default_store ### Parameters #### Query Parameters - **service** (string) - Required - The service name for the keystore. ### Request Body None ### Response #### Success Response (200) - **KeyStore** (object) - The newly created KeyStore instance. #### Response Example ```json { "message": "KeyStore created successfully" } ``` ## POST /keystore/new ### Description Creates a new KeyStore with a specified keystore specification. ### Method POST ### Endpoint /keystore/new ### Parameters #### Query Parameters - **service** (string) - Required - The service name for the keystore. - **keystore_spec** (string) - Required - The specification for the keystore. ### Request Body None ### Response #### Success Response (200) - **KeyStore** (object) - The newly created KeyStore instance. #### Response Example ```json { "message": "KeyStore created successfully" } ``` ``` -------------------------------- ### Get Anytype API Version Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient Demonstrates how to fetch the API version string from the `AnytypeClient`. This is useful for ensuring compatibility or logging purposes. ```rust use anytype::prelude::* let client = AnytypeClient::new("my-app")?; println!("api version: {}", client.api_version()); ``` -------------------------------- ### Initializer API Source: https://docs.rs/anytype/latest/anytype/keystore/enum.KeyStoreType Provides methods for initializing objects. ```APIDOC ## POST /init ### Description Initializes an object with the given initializer. ### Method POST ### Endpoint /init ### Parameters #### Request Body - **init** (T::Init) - Required - The initializer for the object. ### Response #### Success Response (200) - **usize** (usize) - The pointer to the initialized object. ### Request Example ```json { "init": "initializer_value" } ``` ### Response Example ```json { "pointer": 12345 } ``` ``` -------------------------------- ### Create AnytypeClient with App Name Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient Illustrates the basic creation of an `AnytypeClient` instance using a default configuration, identified by an application name. This is the simplest way to initialize the client. ```rust use anytype::prelude::* let client = AnytypeClient::new("my-app")?; ``` -------------------------------- ### Get Verify Configuration from ClientConfig Source: https://docs.rs/anytype/latest/anytype/client/struct.ClientConfig_search= Retrieves an optional reference to the `VerifyConfig` from the `ClientConfig`. Returns `None` if verification is disabled. ```rust pub fn get_verify_config(&self) -> Option<&VerifyConfig> ``` -------------------------------- ### Client Initialization Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient_search=std%3A%3Avec Methods for creating and configuring an Anytype client instance. ```APIDOC ## Client Initialization ### Description Methods for creating and configuring an Anytype client instance. ### `new` #### Description Creates a new client with default configuration. Configure `ClientConfig.keystore` if you want file-based credential storage. #### Method `AnytypeClient::new(app_name: &str) -> Result` #### Example ```rust use anytype::prelude::*; let client = AnytypeClient::new("my-app")?; ``` ### `with_config` #### Description Creates a new client with the provided configuration. Configure `ClientConfig.keystore` if you want file-based credential storage. #### Method `AnytypeClient::with_config(config: ClientConfig) -> Result` #### Example ```rust use anytype::prelude::*; let config = ClientConfig::default().app_name("my-app"); let client = AnytypeClient::with_config(config)?; ``` ### `with_client` #### Description Creates a client from a `reqwest::ClientBuilder` and configuration. `ClientBuilder` can be customized with timeouts, proxies, DNS servers, user_agent, etc. Configure `ClientConfig.keystore` if you want file-based credential storage. #### Method `AnytypeClient::with_client(builder: reqwest::ClientBuilder, config: ClientConfig) -> Result` #### Example ```rust use anytype::prelude::*; let config = ClientConfig::default().app_name("my-app"); let builder = reqwest::Client::builder().timeout(std::time::Duration::from_secs(10)); let client = AnytypeClient::with_client(builder, config)?; ``` ``` -------------------------------- ### Get Template Source: https://docs.rs/anytype/latest/anytype/templates/index_search= Retrieves a specific template by its identifier. This endpoint allows you to get detailed information about a single pre-configured structure. ```APIDOC ## GET /templates/{template_id} ### Description Retrieves a single template by its ID. ### Method GET ### Endpoint /templates/{template_id} ### Parameters #### Path Parameters - **template_id** (string) - Required - The unique identifier of the template to retrieve. ### Request Example ```json { "example": "GET /templates/tpl_abc123" } ``` ### Response #### Success Response (200) - **template** (object) - The template object. - **id** (string) - The unique identifier of the template. - **name** (string) - The name of the template. - **description** (string) - A brief description of the template. - **schema** (object) - The schema defining the structure of the template. #### Response Example ```json { "example": { "template": { "id": "tpl_abc123", "name": "Meeting Notes", "description": "A template for organizing meeting minutes.", "schema": { "type": "object", "properties": { "title": {"type": "string"}, "date": {"type": "string", "format": "date-time"}, "attendees": {"type": "array", "items": {"type": "string"}}, "notes": {"type": "string"} } } } } } ``` ``` -------------------------------- ### ChatSpaceRequest - Get Method Source: https://docs.rs/anytype/latest/anytype/chats/struct.ChatSpaceRequest Retrieves chat space data using the `get` method of the ChatSpaceRequest struct. ```APIDOC ## POST /chats ### Description Retrieves chat space data. ### Method POST ### Endpoint /chats ### Parameters #### Request Body - **self** (ChatSpaceRequest) - Required - The request object containing chat space details. ### Request Example ```json { "request": "ChatSpaceRequest details" } ``` ### Response #### Success Response (200) - **Object** (Object) - The retrieved chat space object. #### Response Example ```json { "response": "Chat space object details" } ``` ``` -------------------------------- ### List Views and Add Objects using Anytype Source: https://docs.rs/anytype/latest/anytype/views/index_search= Demonstrates how to list views for a collection or query and how to add objects to a collection using the anytype library. Requires the `anytype::prelude::*` import and client object. ```rust use anytype::prelude::*; let space_id = "ba000000"; let list_id = "ba111111"; // List views for a collection or query let views = client.list_views(space_id, list_id).list().await?; for view in views.iter() { println!("{} {}", view.id, view.name.as_deref().unwrap_or("(unnamed)")); } // Add objects to a collection client.view_add_objects(space_id, list_id, ["obj1", "obj2"]).await?; ``` -------------------------------- ### Get Type API Source: https://docs.rs/anytype/latest/anytype/types/struct.TypeRequest_search=u32+-%3E+bool Retrieves a single type by its ID. This operation is performed using the `get` method on a `TypeRequest` object. ```APIDOC ## GET /types/{type_id} ### Description Retrieves the type by ID. ### Method GET ### Endpoint `/types/{type_id}` ### Parameters #### Path Parameters - **type_id** (string) - Required - The unique identifier of the type to retrieve. ### Request Body This endpoint does not require a request body. ### Response #### Success Response (200) - **Type** (object) - The type with all its metadata and properties. #### Response Example ```json { "id": "type_id_123", "name": "Example Type", "properties": { "key": "value" } } ``` #### Errors - `AnytypeError::NotFound` if the type doesn’t exist - `AnytypeError::Validation` if IDs are invalid ``` -------------------------------- ### KeyStore Creation Methods (Rust) Source: https://docs.rs/anytype/latest/anytype/keystore/struct.KeyStore_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods for initializing a KeyStore. `new_default_store` uses the platform's default store, while `new` allows specifying a custom keystore specification. ```rust pub fn new_default_store( service: impl Into, ) -> Result pub fn new( service: impl Into, keystore_spec: &str, ) -> Result ``` -------------------------------- ### Rust: PropertyRequest - Get Property Source: https://docs.rs/anytype/latest/anytype/properties/struct.PropertyRequest_search= Implements the `get` method for PropertyRequest, allowing asynchronous retrieval of a property by its ID. It returns the property definition or an error if not found or validation fails. ```rust pub async fn get(self) -> Result // Retrieves the property by ID. // If property has format select or multi-select, call `with_tags()` to also fetch the tag options for the property. // Errors: // * `AnytypeError::NotFound` if the property doesn’t exist // * `AnytypeError::Validation` if IDs are invalid ``` -------------------------------- ### List Properties in Space - Rust Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient_search=std%3A%3Avec Provides an example of listing properties within a given space. You can set a limit for the number of properties to retrieve. This is an asynchronous operation. ```rust let properties = client.properties(&space_id) .limit(50) .list().await?; ``` -------------------------------- ### Create AnytypeClient with Custom Configuration Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient_search=std%3A%3Avec This snippet illustrates creating an `AnytypeClient` with a custom `ClientConfig`. The configuration can be modified before passing it to `with_config`. This requires the `anytype::prelude::*` import. ```rust use anytype::prelude::*; let config = ClientConfig::default().app_name("my-app"); let client = AnytypeClient::with_config(config)?; ``` -------------------------------- ### Example: Update Object with AnytypeClient Source: https://docs.rs/anytype/latest/anytype/objects/struct.UpdateObjectRequest_search= Demonstrates how to use the UpdateObjectRequest builder to modify an existing object's name and body. This example requires the `anytype::prelude::*` import and an active `client` instance. ```rust use anytype::prelude::*; client.update_object(&space_id, &obj.id) .name("Updated Name") .body("# Updated Content") .update().await?; ``` -------------------------------- ### TemplateRequest - Get Template Source: https://docs.rs/anytype/latest/anytype/templates/struct.TemplateRequest The `get` method is an asynchronous function that builds and sends a request to retrieve a single template by its ID. It returns a `Result` which, upon success, contains the requested `Object`. ```APIDOC ## POST /templates ### Description Retrieves a single template by its ID. ### Method POST ### Endpoint /templates ### Parameters #### Request Body - **TemplateRequest** (Object) - Required - A `TemplateRequest` object used to build the request. ### Request Example ```json { "template_id": "your_template_id" } ``` ### Response #### Success Response (200) - **Object** (Object) - The requested template object. #### Response Example ```json { "template_data": "..." } ``` ``` -------------------------------- ### Implement `get` Method for SpaceRequest in Rust Source: https://docs.rs/anytype/latest/anytype/spaces/struct.SpaceRequest_search= Provides the asynchronous `get` method for the SpaceRequest struct. This method is responsible for making the actual request to retrieve the space and returns the space with its metadata or an error if the space is not found. ```rust pub async fn get(self) -> Result ``` -------------------------------- ### Get Property Definition (Rust) Source: https://docs.rs/anytype/latest/anytype/properties/struct.PropertyRequest Details the `get` asynchronous function for PropertyRequest, which retrieves a property's definition. It specifies the return type `Result` and lists possible errors like `NotFound` and `Validation`. ```rust pub async fn get(self) -> Result ``` -------------------------------- ### List Spaces with AnytypeClient in Rust Source: https://docs.rs/anytype/latest/anytype/spaces/struct.ListSpacesRequest_search=std%3A%3Avec Provides examples of how to list spaces using the AnytypeClient. Demonstrates basic listing, listing with filters (like text not containing a specific string), and collecting all spaces across multiple pages. ```rust // List all spaces let spaces = client.spaces().list().await?; // List with filters let spaces = client.spaces() .limit(10) .filter(Filter::text_not_contains("name", "Demo")) .list().await?; // Collect all spaces across pages let all_spaces = client.spaces().list().await?.collect_all().await?; ``` -------------------------------- ### Implement get Method for FileGetRequest in Rust Source: https://docs.rs/anytype/latest/anytype/files/struct.FileGetRequest Provides an asynchronous implementation for the `get` method on the FileGetRequest struct. This method is designed to retrieve a FileObject and returns a Result, indicating potential success or failure during the operation. ```rust pub async fn get(self) -> Result ``` -------------------------------- ### Import Anytype Prelude in Rust Source: https://docs.rs/anytype/latest/anytype/prelude/index This snippet demonstrates how to import all essential components from the Anytype prelude using `use anytype::prelude::*;`. This is the recommended way to include Anytype functionality in your Rust project. ```rust use anytype::prelude::*; fn main() { // You can now use types and functions re-exported by the prelude println!("Anytype prelude imported successfully!"); } ``` -------------------------------- ### TagRequest Methods: Get and Delete Tag Source: https://docs.rs/anytype/latest/anytype/tags/struct.TagRequest Provides asynchronous methods for the TagRequest struct. 'get' retrieves a tag by its ID, returning a Result. 'delete' removes the tag, also returning a Result. ```rust pub async fn get(self) -> Result Retrieves the tag by ID. ``` ```rust pub async fn delete(self) -> Result Deletes the tag. ``` -------------------------------- ### Structs: AnytypeClient and ClientConfig Source: https://docs.rs/anytype/latest/anytype/client/index_search=u32+-%3E+bool Details about the main client structure and its configuration. ```APIDOC ## Structs ### `AnytypeClient` - **Description**: An ergonomic Anytype API client implemented in Rust. ### `ClientConfig` - **Description**: Configuration structure for the Anytype client. It defines settings such as the endpoint URL, validation limits, and other operational parameters. ``` -------------------------------- ### Get Type using TypeRequest Source: https://docs.rs/anytype/latest/anytype/types/struct.TypeRequest_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Asynchronously retrieves a type by its ID using the `get` method of the TypeRequest struct. This operation returns the type with all its metadata and properties upon success. It can fail if the type is not found or if the provided IDs are invalid. ```rust pub async fn get(self) -> Result ``` -------------------------------- ### Create GrpcCredentials Instance Source: https://docs.rs/anytype/latest/anytype/keystore/struct.GrpcCredentials_search=std%3A%3Avec Provides methods for creating GrpcCredentials instances. `new` takes optional credentials, `from_token` and `from_account_key` create instances from specific credentials, and `with_*` methods allow chaining to add credentials. ```rust pub fn new( account_id: Option, account_key: Option, session_token: Option, ) -> Self ``` ```rust pub fn from_token(token: impl Into) -> Self ``` ```rust pub fn from_account_key(account_key: impl Into) -> Self ``` ```rust pub fn with_account_id(self, account_id: impl Into) -> Self ``` ```rust pub fn with_account_key(self, account_key: impl Into) -> Self ``` ```rust pub fn with_session_token(self, token: impl Into) -> Self ``` -------------------------------- ### Example: Multi-Select In Filter in Rust Source: https://docs.rs/anytype/latest/anytype/filters/enum.Filter Shows an example of using the `multi_select_in` helper function in Rust to create a filter. This filter matches entries where a multi-select property contains any of the values provided in an iterator. It requires importing `Filter` from `anytype::prelude`. ```rust use anytype::prelude::Filter; let filter = Filter::multi_select_in("tags", vec!["urgent", "critical"]); ``` -------------------------------- ### Files Client Source: https://docs.rs/anytype/latest/anytype/client/struct.AnytypeClient_search=u32+-%3E+bool Entry point for file-related operations. ```APIDOC ## Files Client ### Description Entry point for file-related operations. ### GET /files #### Description Provides access to the FilesClient for managing files. ### Method GET ### Endpoint /files ### Response #### Success Response (200) - **files_client** (object) - An object representing the FilesClient. #### Response Example (Note: This endpoint likely returns a client object that is then used for subsequent file operations, which are not detailed here.) ``` -------------------------------- ### TypeRequest: Get and Delete Type (Rust) Source: https://docs.rs/anytype/latest/anytype/types/struct.TypeRequest Demonstrates how to use the TypeRequest struct to retrieve or delete a type. The `get` method fetches type details, while `delete` archives it. Both operations return a Result which may contain the Type or an AnytypeError like NotFound or Forbidden. ```rust pub struct TypeRequest { /* private fields */ } impl TypeRequest { // Retrieves the type by ID. // Returns: The type with all its metadata and properties. // Errors: AnytypeError::NotFound if the type doesn’t exist, AnytypeError::Validation if IDs are invalid. pub async fn get(self) -> Result // Deletes (archives) the type. // Returns: The deleted type. // Errors: AnytypeError::NotFound if the type doesn’t exist, AnytypeError::Forbidden if you don’t have permission. pub async fn delete(self) -> Result } ``` -------------------------------- ### ClientConfig Builder Methods Source: https://docs.rs/anytype/latest/anytype/client/struct.ClientConfig_search=std%3A%3Avec Methods available on ClientConfig for fluent configuration. ```APIDOC ## impl ClientConfig ### Methods * **`app_name(self, app_name: &str) -> Self`**: Sets the application name. * **`limits(self, limits: ValidationLimits) -> Self`**: Sets the validation limits. * **`disable_cache(self, disable_cache: bool) -> Self`**: Disables the in-memory cache. * **`ensure_available(self, verify: VerifyConfig) -> Self`**: Enables read-after-write verification using the provided config. * **`verify_config(self, verify: Option) -> Self`**: Explicitly sets the verification configuration (`None` disables verification). * **`grpc_endpoint(self, endpoint: String) -> Self`**: Sets the gRPC endpoint, overriding the default. * **`get_limits(&self) -> &ValidationLimits`**: Returns a reference to the current validation limits. * **`get_verify_config(&self) -> Option<&VerifyConfig>`**: Returns an optional reference to the verification configuration. ``` -------------------------------- ### Get Space Source: https://docs.rs/anytype/latest/anytype/spaces/index_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves a specific space by its ID. ```APIDOC ## GET /spaces/{space_id} ### Description Retrieves a specific space by its ID. ### Method GET ### Endpoint /spaces/{space_id} ### Parameters #### Path Parameters - **space_id** (string) - Required - The unique identifier of the space to retrieve. ### Request Example ```rust let space = client.space("space_id").get().await?; ``` ### Response #### Success Response (200) - **space** (object) - The Space object representing the requested space. #### Response Example ```json { "id": "space_id", "name": "My Space", "description": "A workspace for my projects" } ``` ``` -------------------------------- ### PolicyExt Implementations Source: https://docs.rs/anytype/latest/anytype/keystore/enum.KeyStoreType_search=std%3A%3Avec Provides methods to combine policies, creating new policies that enforce sequential or alternative conditions. ```APIDOC ## PolicyExt Implementations ### Description This section details the `PolicyExt` trait, which allows for the creation of new policies by combining existing ones. ### Methods #### `and(self, other: P) -> And` - **Description**: Creates a new `Policy` that returns `Action::Follow` only if both `self` and `other` policies return `Action::Follow`. - **Type Parameters**: `P` (the type of the other policy), `B` (the type of the binding), `E` (the type of the error). - **Constraints**: `T: Policy`, `P: Policy`. #### `or(self, other: P) -> Or` - **Description**: Creates a new `Policy` that returns `Action::Follow` if either `self` or `other` policies return `Action::Follow`. - **Type Parameters**: `P` (the type of the other policy), `B` (the type of the binding), `E` (the type of the error). - **Constraints**: `T: Policy`, `P: Policy`. ``` -------------------------------- ### TryFrom API Source: https://docs.rs/anytype/latest/anytype/keystore/enum.KeyStoreType Provides a method for fallibly converting one type into another. ```APIDOC ## POST /try_from ### Description Performs the conversion from type U to type T. ### Method POST ### Endpoint /try_from ### Parameters #### Request Body - **value** (U) - Required - The value to convert. ### Response #### Success Response (200) - **result** (Result>::Error>) - The result of the conversion. ### Request Example ```json { "value": "value_of_u" } ``` ### Response Example ```json { "result": { "Ok": "value_of_t" } } ``` ```json { "result": { "Err": "conversion_error" } } ``` ``` -------------------------------- ### Get Link Source: https://docs.rs/anytype/latest/anytype/objects/struct.Object Retrieves the web link associated with the object. ```APIDOC ## GET /websites/rs_anytype_anytype/link ### Description Returns the web link to the object. ### Method GET ### Endpoint `/websites/rs_anytype_anytype/link` ### Response #### Success Response (200) - **link** (string) - The web link to the object. #### Response Example ```json { "link": "https://example.com/object/123" } ``` ``` -------------------------------- ### Rust: ClientConfig Builder Methods Source: https://docs.rs/anytype/latest/anytype/client/struct.ClientConfig Illustrates various builder pattern methods available for the `ClientConfig` struct in Rust. These methods allow for fluent configuration of client settings such as application name, validation limits, cache disabling, verification, and gRPC endpoint. ```rust impl ClientConfig { // ... other methods pub fn app_name(self, app_name: &str) -> Self pub fn limits(self, limits: ValidationLimits) -> Self pub fn disable_cache(self, disable_cache: bool) -> Self pub fn ensure_available(self, verify: VerifyConfig) -> Self pub fn verify_config(self, verify: Option) -> Self pub fn grpc_endpoint(self, endpoint: String) -> Self // ... other methods } ``` -------------------------------- ### Any Trait Implementation Source: https://docs.rs/anytype/latest/anytype/chats/struct.ChatClient_search=std%3A%3Avec Provides the `type_id` method to get the `TypeId` of an object. ```APIDOC ## impl Any for T ### Description This is a blanket implementation for the `Any` trait, allowing any type `T` that is `'static + ?Sized` to use the methods provided by the `Any` trait. ### Method - `type_id(&self) -> TypeId`: Gets the `TypeId` of `self`. ### Endpoint N/A (This is a trait implementation, not an API endpoint) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (N/A) - `TypeId`: The unique identifier for the type of `self`. #### Response Example N/A ``` -------------------------------- ### Get Template Source: https://docs.rs/anytype/latest/anytype/templates/index Retrieves details for a specific template. This endpoint uses a builder pattern for constructing the request. ```APIDOC ## GET /templates/{template_id} ### Description Retrieves details for a specific template. ### Method GET ### Endpoint /templates/{template_id} ### Parameters #### Path Parameters - **template_id** (string) - Required - The unique identifier of the template to retrieve. ### Request Example ```json { "template_id": "template_123" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the template. - **name** (string) - The name of the template. - **description** (string) - A description of the template. - **schema** (object) - The schema definition of the template. #### Response Example ```json { "id": "template_123", "name": "Meeting Notes", "description": "A template for meeting minutes.", "schema": { "type": "object", "properties": { "title": {"type": "string"}, "date": {"type": "string", "format": "date"}, "attendees": {"type": "array", "items": {"type": "string"}} } } } ``` ``` -------------------------------- ### Layer and VZip Implementations Source: https://docs.rs/anytype/latest/anytype/files/struct.FileUploadRequest_search=std%3A%3Avec Illustrates implementations for applying layers to services and for vector zipping operations. This includes `LayerExt` for creating named layers and `VZip` for vector operations. ```Rust impl LayerExt for L fn named_layer(&self, service: S) -> Layered<>::Service, S> where L: Layer, impl VZip for T where V: MultiLane, fn vzip(self) -> V ``` -------------------------------- ### Pointer Initialization and Dereferencing Source: https://docs.rs/anytype/latest/anytype/keystore/enum.KeyStoreType_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Functions for initializing, dereferencing, and mutably dereferencing pointers, as well as dropping the object they point to. ```APIDOC ## Pointer Operations ### Description Provides functions for managing raw pointers, including initialization, dereferencing, and cleanup. ### `init` #### Signature `unsafe fn init(init: ::Init) -> usize` #### Description Initializes an object with the given initializer and returns its pointer address. ### `deref` #### Signature `unsafe fn deref<'a>(ptr: usize) -> &'a T` #### Description Dereferences the given pointer to provide an immutable reference to the object. ### `deref_mut` #### Signature `unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T` #### Description Mutably dereferences the given pointer to provide a mutable reference to the object. ### `drop` #### Signature `unsafe fn drop(ptr: usize)` #### Description Drops the object pointed to by the given pointer, releasing its resources. ``` -------------------------------- ### Get Template Source: https://docs.rs/anytype/latest/anytype/templates/index_search=std%3A%3Avec Fetches the details of a specific template by its identifier. This endpoint is part of the Anytype Templates module. ```APIDOC ## GET /templates/{template_id} ### Description Retrieves the details of a specific template. ### Method GET ### Endpoint /templates/{template_id} ### Parameters #### Path Parameters - **template_id** (string) - Required - The unique identifier of the template to retrieve. ### Request Example ```json { "template_id": "tpl_abc123" } ``` ### Response #### Success Response (200) - **template_id** (string) - The unique identifier for the template. - **name** (string) - The name of the template. - **description** (string) - A brief description of the template. - **structure** (object) - The structural definition of the template. #### Response Example ```json { "template_id": "tpl_abc123", "name": "Meeting Notes", "description": "A template for organizing meeting minutes.", "structure": { "fields": [ { "name": "Date", "type": "date" }, { "name": "Attendees", "type": "text" }, { "name": "Discussion Points", "type": "rich_text" } ] } } ``` ``` -------------------------------- ### Get a Specific Tag Source: https://docs.rs/anytype/latest/anytype/tags/index_search=std%3A%3Avec Retrieves details for a specific tag associated with a property. ```APIDOC ## GET /spaces/{space_id}/properties/{property_id}/tags/{tag_id} ### Description Retrieves the details of a specific tag for a given property. ### Method GET ### Endpoint /spaces/{space_id}/properties/{property_id}/tags/{tag_id} ### Parameters #### Path Parameters - **space_id** (string) - Required - The unique identifier for the space. - **property_id** (string) - Required - The unique identifier for the property. - **tag_id** (string) - Required - The unique identifier for the tag. ### Request Example ``` // No request body for GET request ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the tag. - **name** (string) - The name of the tag. - **color** (string) - The color associated with the tag (e.g., "#FF0000"). #### Response Example ```json { "id": "tag_id_1", "name": "Urgent", "color": "#FF0000" } ``` ``` -------------------------------- ### TryInto API Source: https://docs.rs/anytype/latest/anytype/keystore/enum.KeyStoreType Provides a method for fallibly converting one type into another using `TryInto`. ```APIDOC ## POST /try_into ### Description Performs the conversion from type T to type U. ### Method POST ### Endpoint /try_into ### Parameters #### Request Body - **self** (T) - Required - The value to convert. ### Response #### Success Response (200) - **result** (Result>::Error>) - The result of the conversion. ### Request Example ```json { "value": "value_of_t" } ``` ### Response Example ```json { "result": { "Ok": "value_of_u" } } ``` ```json { "result": { "Err": "conversion_error" } } ``` ``` -------------------------------- ### List Chat Messages with Anytype Client Source: https://docs.rs/anytype/latest/anytype/chats/index_search= Demonstrates how to list chat messages using the Anytype client. It shows how to specify a chat ID, limit the number of messages, and retrieve a page of results. The example also prints the number of unread messages and the content of the latest message. ```rust use anytype::prelude::*; let chat_id = "chat_object_id"; let page = client .chats() .list_messages(chat_id) .limit(20) .list_page() .await?; println!("unread: {}", page.state.messages_unread); println!( "latest message: {}", page.messages .first() .map(|m| &m.content.text) .unwrap_or(&"\".into()) ); ``` -------------------------------- ### Get Shared Link Source: https://docs.rs/anytype/latest/anytype/objects/struct.Object Generates a web link to the object with a share invite. ```APIDOC ## POST /websites/rs_anytype_anytype/link/shared ### Description Returns a web link to the object with a share invite. ### Method POST ### Endpoint `/websites/rs_anytype_anytype/link/shared` ### Parameters #### Request Body - **cid** (str) - Required - The collection ID. - **key** (str) - Required - The share key. ### Request Example ```json { "cid": "collection_abc", "key": "share_xyz" } ``` ### Response #### Success Response (200) - **link** (string) - The shared web link to the object. #### Response Example ```json { "link": "https://example.com/shared/object/123?invite=share_xyz" } ``` ``` -------------------------------- ### Get Object Web Link Source: https://docs.rs/anytype/latest/anytype/objects/struct.Object Returns the web link associated with the object. ```rust pub fn get_link(&self) -> String ```