OxL Справочник OxL
РусскийEnglish

fn emitCondOf

emitOf for a topic whose policy has conditions (bits as for publishCondOf). The generated code of emit Topic(x) calls it.

Example:

oxl✓ проверяется в CI
use std.rpc { asScoped }

data Ev {
  userId: str
  amount: i64
}

topic Evs: Ev sharded by .userId

// a condition of a rule can look at the key, the element and the caller
policy Evs {
  allow publish if caller.isUser(key) && element.amount <= 100
  deny publish if element.amount < 0
}

cluster demo {
  role store { journal }
}

fn user(id: str) -> Principal {
  Principal.User(id, [], Map.new(), false, none)
}

fn announce() io, db {
  asScoped(user("a")) {
    emit Evs(Ev{ userId: "a", amount: 5 })
  }
}
pub(api) fn emitCondOf<T: Serializable>(h: i64, x: &T, key: bytes, bits: i64) db

С версии. 1.0.0-beta

Параметры

ИмяТип
hi64
x&T
keybytes
bitsi64

Ошибки

panics when the element cannot be stored or the policy refuses it.

Эффекты

db

Определено в: std/topic/topic.oxl:332

См. также