Struct meilisearch_sdk::key::KeyBuilder
source · pub struct KeyBuilder {
pub actions: Vec<Action>,
pub description: Option<String>,
pub name: Option<String>,
pub uid: Option<String>,
pub expires_at: Option<OffsetDateTime>,
pub indexes: Vec<String>,
}Expand description
The KeyBuilder is an analog to the Key type but without all the fields managed by Meilisearch. It’s used to create Key.
Example
let client = Client::new(MEILISEARCH_URL, MEILISEARCH_API_KEY);
let description = "My little lovely test key".to_string();
let key = KeyBuilder::new()
.with_description(&description)
.execute(&client).await.unwrap();
Fields§
§actions: Vec<Action>§description: Option<String>§name: Option<String>§uid: Option<String>§expires_at: Option<OffsetDateTime>§indexes: Vec<String>Implementations§
source§impl KeyBuilder
impl KeyBuilder
sourcepub fn new() -> KeyBuilder
pub fn new() -> KeyBuilder
sourcepub fn with_actions(
&mut self,
actions: impl IntoIterator<Item = Action>
) -> &mut Self
pub fn with_actions(
&mut self,
actions: impl IntoIterator<Item = Action>
) -> &mut Self
sourcepub fn with_action(&mut self, action: Action) -> &mut Self
pub fn with_action(&mut self, action: Action) -> &mut Self
sourcepub fn with_expires_at(&mut self, expires_at: OffsetDateTime) -> &mut Self
pub fn with_expires_at(&mut self, expires_at: OffsetDateTime) -> &mut Self
sourcepub fn with_indexes(
&mut self,
indexes: impl IntoIterator<Item = impl AsRef<str>>
) -> &mut Self
pub fn with_indexes(
&mut self,
indexes: impl IntoIterator<Item = impl AsRef<str>>
) -> &mut Self
sourcepub fn with_index(&mut self, index: impl AsRef<str>) -> &mut Self
pub fn with_index(&mut self, index: impl AsRef<str>) -> &mut Self
sourcepub fn with_description(&mut self, desc: impl AsRef<str>) -> &mut Self
pub fn with_description(&mut self, desc: impl AsRef<str>) -> &mut Self
Add a description to the key.
Example
let description = "My not so little lovely test key".to_string();
let mut key = KeyBuilder::new()
.with_description(&description)
.execute(&client).await.unwrap();
sourcepub fn with_name(&mut self, desc: impl AsRef<str>) -> &mut Self
pub fn with_name(&mut self, desc: impl AsRef<str>) -> &mut Self
Add a name to the key.
Example
let name = "lovely key".to_string();
let mut key = KeyBuilder::new()
.with_name(&name)
.execute(&client).await.unwrap();
sourcepub fn with_uid(&mut self, desc: impl AsRef<str>) -> &mut Self
pub fn with_uid(&mut self, desc: impl AsRef<str>) -> &mut Self
Add an uid to the key.
Example
let uid = "93bcd7fb-2196-4fd9-acb7-3fca8a96e78f".to_string();
let mut key = KeyBuilder::new()
.with_uid(&uid)
.execute(&client).await.unwrap();
Trait Implementations§
source§impl AsRef<KeyBuilder> for KeyBuilder
impl AsRef<KeyBuilder> for KeyBuilder
source§fn as_ref(&self) -> &KeyBuilder
fn as_ref(&self) -> &KeyBuilder
Converts this type into a shared reference of the (usually inferred) input type.
source§impl Debug for KeyBuilder
impl Debug for KeyBuilder
source§impl Default for KeyBuilder
impl Default for KeyBuilder
source§fn default() -> KeyBuilder
fn default() -> KeyBuilder
Returns the “default value” for a type. Read more