pub struct KeyBuilder {
    pub actions: Vec<Action>,
    pub description: 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("http://localhost:7700", "masterKey");

let key = KeyBuilder::new("My little lovely test key")
  .with_action(Action::DocumentsAdd)
  .with_index("*")
  .create(&client).await.unwrap();

assert_eq!(key.description, "My little lovely test key");

Fields

actions: Vec<Action>description: Stringexpires_at: Option<OffsetDateTime>indexes: Vec<String>

Implementations

Create a KeyBuilder with only a description.

Example
let builder = KeyBuilder::new("My little lovely test key");

Declare a set of actions the Key will be able to execute.

Example
let mut builder = KeyBuilder::new("My little lovely test key");
builder.with_actions(vec![Action::Search, Action::DocumentsAdd]);

Add one action the Key will be able to execute.

Example
let mut builder = KeyBuilder::new("My little lovely test key");
builder.with_action(Action::DocumentsAdd);

Set the expiration date of the Key.

Example
use time::{OffsetDateTime, Duration};
let mut builder = KeyBuilder::new("My little lovely test key");
// create a key that expires in two weeks from now
builder.with_expires_at(OffsetDateTime::now_utc() + Duration::WEEK * 2);

Set the indexes the Key can manage.

Example
let mut builder = KeyBuilder::new("My little lovely test key");
builder.with_indexes(vec!["test", "movies"]);

Add one index the Key can manage.

Example
let mut builder = KeyBuilder::new("My little lovely test key");
builder.with_index("test");

Create a Key from the builder.

Example
let client = Client::new("http://localhost:7700", "masterKey");
let key = KeyBuilder::new("My little lovely test key")
  .create(&client).await.unwrap();

assert_eq!(key.description, "My little lovely test key");

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Formats the value using the given formatter. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more