LogLineBuilder

Struct LogLineBuilder 

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

Builder para construir um LogLine passo a passo.

Use LogLine::builder() para criar um novo builder. Todos os campos obrigatórios devem ser fornecidos antes de chamar build_draft().

§Exemplo

use logline_core::*;

let line = LogLine::builder()
    .who("did:ubl:alice")
    .did(Verb::Transfer)
    .this(Payload::Text("100 USD".into()))
    .when(1_735_671_234)
    .if_ok(Outcome { label: "transferred".into(), effects: vec!["emit_receipt".into()] })
    .if_doubt(Escalation { label: "verify".into(), route_to: "auditor".into() })
    .if_not(FailureHandling { label: "failed".into(), action: "compensate".into() })
    .build_draft()?;

Implementations§

Source§

impl LogLineBuilder

Source

pub fn new() -> Self

Source

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

Define o agente que executa a ação (DID futuro, ex: did:ubl:...).

Source

pub fn did(self, v: Verb) -> Self

Define o verbo da ação (canônico ou custom).

Source

pub fn this(self, v: Payload) -> Self

Define a carga útil da ação (payload).

Source

pub fn when(self, v: u64) -> Self

Define o timestamp Unix em nanosegundos.

Source

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

Define a identidade que confirma a ação (opcional).

Paper I: obrigatório para ações de Risk Level 3+ (L3+).

Source

pub fn if_ok(self, v: Outcome) -> Self

Define a consequência positiva obrigatória (invariant).

Source

pub fn if_doubt(self, v: Escalation) -> Self

Define a via de dúvida obrigatória (invariant).

Source

pub fn if_not(self, v: FailureHandling) -> Self

Define o fallback/erro obrigatório (invariant).

Source

pub fn build_draft(self) -> Result<LogLine, LogLineError>

Constrói um DRAFT válido (invariants obrigatórios presentes).

Valida que todos os campos obrigatórios estão presentes e cria um LogLine com status Draft. Os invariants são verificados antes de retornar.

§Erros
  • LogLineError::MissingField se algum campo obrigatório estiver faltando
  • LogLineError::MissingInvariant se algum invariant estiver faltando ou vazio
§Campos obrigatórios
  • who: identidade do agente
  • did: verbo da ação
  • when: timestamp
  • if_ok: consequência positiva
  • if_doubt: via de dúvida
  • if_not: fallback/erro

Trait Implementations§

Source§

impl Default for LogLineBuilder

Source§

fn default() -> LogLineBuilder

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.