OxL Reference

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✓ checked in 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

Since. 1.0.0-beta

Parameters

NameType
hi64
x&T
keybytes
bitsi64

Errors

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

Effects

db

Defined in: std/topic/topic.oxl:332

See also