Skip to main content

DeliveryMetadata

Struct DeliveryMetadata 

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

English:
Owned delivery identifiers, independent of the domain event payload.

Strings are stored without format or emptiness validation. Providing an event identifier does not enforce uniqueness or deduplication; correlation and causation are optional labels.

Attach tracing labels without changing the event identifier.

日本語:
ドメインイベントのペイロードから独立した、所有された配信識別子です。

文字列の形式や空文字列は検証しません。イベント識別子の指定は一意性や重複排除を 強制しません。相関識別子と原因識別子は任意のラベルです。

イベント識別子を変えずにトレース用のラベルを付けます。

§Example / 使用例

use ddd_toolkit_core::DeliveryMetadata;

let metadata = DeliveryMetadata::new("event-1")
    .with_correlation_id("request-7")
    .with_causation_id("command-2");
assert_eq!(metadata.event_id(), "event-1");
assert_eq!(metadata.correlation_id(), Some("request-7"));
assert_eq!(metadata.causation_id(), Some("command-2"));

Implementations§

Source§

impl DeliveryMetadata

Source

pub fn new(event_id: impl Into<String>) -> DeliveryMetadata

English:
Stores event_id after conversion to String, leaving both optional IDs unset. No identifier validation or generation is performed.

日本語:
event_id を String に変換して保存し、二つの任意識別子は未設定にします。 識別子の検証や生成は行いません。

Source

pub fn with_correlation_id(self, id: impl Into<String>) -> DeliveryMetadata

English:
Consumes this value and returns it with the correlation ID set to id. A previously set correlation ID is replaced.

日本語:
自身を消費し、相関識別子を id に設定して返します。 設定済みの相関識別子は置き換えます。

Source

pub fn with_causation_id(self, id: impl Into<String>) -> DeliveryMetadata

English:
Consumes this value and sets the causation ID to id, replacing any prior value.

日本語:
自身を消費し、原因識別子を id に設定します。以前の値は置き換えます。

Source

pub fn event_id(&self) -> &str

English:
Borrows the event identifier as stored, without allocating.

日本語:
保存されたイベント識別子を、割り当てなしで借用します。

Source

pub fn correlation_id(&self) -> Option<&str>

English:
Borrows the correlation ID, or returns None if it has not been set.

日本語:
相関識別子を借用し、未設定なら None を返します。

Source

pub fn causation_id(&self) -> Option<&str>

English:
Borrows the causation ID, or returns None when no cause label is stored.

日本語:
原因識別子を借用し、原因のラベルが保存されていなければ None を返します。

Trait Implementations§

Source§

impl Clone for DeliveryMetadata

Source§

fn clone(&self) -> DeliveryMetadata

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeliveryMetadata

Source§

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

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

impl Eq for DeliveryMetadata

Source§

impl Hash for DeliveryMetadata

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DeliveryMetadata

Source§

fn eq(&self, other: &DeliveryMetadata) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DeliveryMetadata

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.