Skip to main content

EventBuilder

Struct EventBuilder 

Source
pub struct EventBuilder { /* private fields */ }
Expand description

Builder for constructing Event instances.

Implementations§

Source§

impl EventBuilder

Source

pub fn new() -> Self

Creates a new EventBuilder.

Source

pub fn id(self, id: EventId) -> Self

Sets the event ID.

Source

pub fn location(self, location: Location) -> Self

Sets the location.

Source

pub fn coordinates(self, lat: f64, lon: f64) -> Self

Sets the location from coordinates.

Source

pub fn timestamp(self, timestamp: Timestamp) -> Self

Sets the timestamp.

Source

pub fn timestamp_str(self, s: &str) -> Result<Self>

Sets the timestamp from a parseable string.

Source

pub fn text(self, text: impl Into<String>) -> Self

Sets the event text.

Source

pub fn tag(self, tag: impl Into<String>) -> Self

Adds a tag.

Source

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

Adds multiple tags.

Source

pub fn source(self, source: SourceRef) -> Self

Adds a source reference.

Source

pub fn sources(self, sources: impl IntoIterator<Item = SourceRef>) -> Self

Adds multiple sources.

Source

pub fn metadata(self, key: impl Into<String>, value: impl Into<String>) -> Self

Sets a metadata value.

Source

pub fn build(self) -> Event

Builds the Event.

Uses current time if timestamp is not set. Uses empty string if text is not set.

Source

pub fn try_build(self) -> Result<Event>

Builds the Event, returning an error if required fields are missing.

Trait Implementations§

Source§

impl Debug for EventBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for EventBuilder

Source§

fn default() -> EventBuilder

Returns the “default value” for a type. 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, 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.