pub struct Batch { /* private fields */ }
Expand description

Represents a batch of Microsoft Dataverse Requests

Some restrictions apply for creating batches:

  • the batch size may not exceed 1000 calls
  • the batch execution time may not exceed 2 minutes

the second restriction is especially tricky to handle because the execution time depends on the complexity of the entity in dataverse. So it is possible to create 300 records of an entity with low complexity but only 50 records of an entity with high complexity in that timeframe.

Based on experience a batch size of 50 should be safe for all entities though

Examples

let testy_contact = Contact {
    contactid: Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap(),
    firstname: String::from("Testy"),
    lastname: String::from("McTestface"),
};

let marianne_contact = Contact {
    contactid: Uuid::parse_str("12345678-1234-1234-1234-123456789abc").unwrap(),
    firstname: String::from("Marianne"),
    lastname: String::from("McTestface"),
};

// this batch creates both contacts in one call
let mut batch = Batch::new("https://instance.crm.dynamics.com/");
batch.create(&testy_contact).unwrap();
batch.create(&marianne_contact).unwrap();

client.execute(&batch).unwrap();

#[derive(Serialize)]
struct Contact {
    contactid: Uuid,
    firstname: String,
    lastname: String,
}

impl WriteEntity for Contact {}

impl Reference for Contact {
    fn get_reference(&self) -> ReferenceStruct {
        ReferenceStruct::new(
            "contacts",
            self.contactid,
        )
    }
}

Implementations

Creates a new empty batch with its own batch id and dataset id

Clears the batch of its contents and generates a new batch id and a new dataset id

Note that this can be used to prevent frequent allocations by reusing the Batch instance and its buffer

returns the current batch id (This can change after a call to reset() though)

returns the current dataset id (This can change after a call to reset() though)

returns the current count auf requests in this batch

Adds a Create Request for the given entity to this batch

Please note that this function can fail if a serde serialization error occurs

Examples
let testy_contact = Contact {
    contactid: Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap(),
    firstname: String::from("Testy"),
    lastname: String::from("McTestface"),
};

let marianne_contact = Contact {
    contactid: Uuid::parse_str("12345678-1234-1234-1234-123456789abc").unwrap(),
    firstname: String::from("Marianne"),
    lastname: String::from("McTestface"),
};

// this batch creates both contacts in one call
let mut batch = Batch::new("https://instance.crm.dynamics.com/");
batch.create(&testy_contact).unwrap();
batch.create(&marianne_contact).unwrap();

Adds an Update Request for the given entity to this batch

Please note that this function can fail if a serde serialization error occurs

Examples
let testy_contact = Contact {
    contactid: Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap(),
    firstname: String::from("Testy"),
    lastname: String::from("McTestface"),
};

let marianne_contact = Contact {
    contactid: Uuid::parse_str("12345678-1234-1234-1234-123456789abc").unwrap(),
    firstname: String::from("Marianne"),
    lastname: String::from("McTestface"),
};

// this batch updates both contacts in one call
let mut batch = Batch::new("https://instance.crm.dynamics.com/");
batch.update(&testy_contact).unwrap();
batch.update(&marianne_contact).unwrap();

Adds an Upsert Request for the given entity to this batch

Please note that this function can fail if a serde serialization error occurs

Examples
let testy_contact = Contact {
    contactid: Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap(),
    firstname: String::from("Testy"),
    lastname: String::from("McTestface"),
};

let marianne_contact = Contact {
    contactid: Uuid::parse_str("12345678-1234-1234-1234-123456789abc").unwrap(),
    firstname: String::from("Marianne"),
    lastname: String::from("McTestface"),
};

// this batch creates both contacts in one call
let mut batch = Batch::new("https://instance.crm.dynamics.com/");
batch.upsert(&testy_contact).unwrap();
batch.upsert(&marianne_contact).unwrap();

Adds a Delete Request for the given entity reference to this batch

Please note that this function can fail if a serde serialization error occurs

Examples
let testy_reference = ReferenceStruct::new(
    "contacts",
    Uuid::parse_str("12345678-1234-1234-1234-123456789012").unwrap()
);

let marianne_reference = ReferenceStruct::new(
    "contacts",
    Uuid::parse_str("12345678-1234-1234-1234-123456789abc").unwrap()
);

// this batch creates both contacts in one call
let mut batch = Batch::new("https://instance.crm.dynamics.com/");
batch.delete(&testy_reference).unwrap();
batch.delete(&marianne_reference).unwrap();

Trait Implementations

Formats the value using the given formatter. 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

Calls U::from(self).

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

Converts the given value to a String. Read more

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