AnalyticsEngineDataPointBuilder

Struct AnalyticsEngineDataPointBuilder 

Source
pub struct AnalyticsEngineDataPointBuilder { /* private fields */ }

Implementations§

Source§

impl AnalyticsEngineDataPointBuilder

Source

pub fn new() -> Self

Source

pub fn indexes<'index>(self, indexes: impl AsRef<[&'index str]>) -> Self

Sets the index values for the data point. While the indexes field accepts an array, you currently must only provide a single index. If you attempt to provide multiple indexes, your data point will not be recorded.

§Arguments
  • index: A string or byte-array value to use as the index.

returns: AnalyticsEngineDataPointBuilder

§Examples
 use worker::AnalyticsEngineDataPointBuilder;

 let data = AnalyticsEngineDataPointBuilder::new()
    .indexes(["index1"])
    .build();
Source

pub fn add_double(self, double: impl Into<f64>) -> Self

Adds a numeric value to the end of the array of doubles.

§Arguments
  • double: The numeric values that you want to record in your data point

returns: AnalyticsEngineDataPointBuilder

§Examples
 use worker::AnalyticsEngineDataPointBuilder;
 let point = AnalyticsEngineDataPointBuilder::new()
    .indexes(["index1"])
    .add_double(25)     // double1
    .add_double(0.5)    // double2
    .build();
 println!("{:?}", point);
Source

pub fn doubles(self, doubles: impl IntoIterator<Item = f64>) -> Self

Set doubles1-20 with the provide values. This method will remove any doubles previously added using the add_double method.

§Arguments
  • doubles: An array of doubles

returns: AnalyticsEngineDataPointBuilder

§Examples
 use worker::AnalyticsEngineDataPointBuilder;
 let point = AnalyticsEngineDataPointBuilder::new()
    .indexes(["index1"])
    .add_double(1) // value will be replaced by the following line
    .doubles([1, 2, 3]) // sets double1, double2 and double3
    .build();
 println!("{:?}", point);
Source

pub fn add_blob(self, blob: impl Into<BlobType>) -> Self

Adds a blob-like value to the end of the array of blobs.

§Arguments
  • blob: The blob values that you want to record in your data point

returns: AnalyticsEngineDataPointBuilder

§Examples
 use worker::AnalyticsEngineDataPointBuilder;
 let point = AnalyticsEngineDataPointBuilder::new()
    .indexes(["index1"])
    .add_blob("Seattle")            // blob1
    .add_blob("USA")                // blob2
    .add_blob("pro_sensor_9000")    // blob3
    .build();
 println!("{:?}", point);
Source

pub fn blobs(self, blobs: impl IntoIterator<Item = impl Into<BlobType>>) -> Self

Sets blobs1-20 with the provided array, replacing any values previously stored using add_blob.

§Arguments
  • blob: The blob values that you want to record in your data point

returns: AnalyticsEngineDataPointBuilder

§Examples
 use worker::AnalyticsEngineDataPointBuilder;
 let point = AnalyticsEngineDataPointBuilder::new()
    .indexes(["index1"])
    .blobs(["Seattle", "USA", "pro_sensor_9000"]) // sets blob1, blob2, and blob3
    .build();
 println!("{:?}", point);
Source

pub fn build(self) -> AnalyticsEngineDataPoint

Source

pub fn write_to(self, dataset: &AnalyticsEngineDataset) -> Result<()>

Write the data point to the provided analytics engine dataset. This is a convenience method that can be used in place of a .build() followed by a call to dataset.write_data_point(point).

§Arguments
  • dataset: Analytics engine dataset binding

returns: worker::Result<()>

§Examples
 use worker::{Env, AnalyticsEngineDataPointBuilder, Response};
 use std::io::Error;

 fn main(env: Env) -> worker::Result<Response> {
    let dataset = match env.analytics_engine("HTTP_ANALYTICS") {
        Ok(dataset) => dataset,
        Err(err) => return Response::error(format!("Failed to get dataset: {err:?}"), 500),
    };

    AnalyticsEngineDataPointBuilder::new()
        .indexes(vec!["index1"].as_slice())
        .add_blob("GET") // blob1
        .add_double(200) // double1
        .write_to(&dataset)?;

    Response::ok("OK")
}

Trait Implementations§

Source§

impl Debug for AnalyticsEngineDataPointBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,