Skip to main content

EXAMPLE_SOURCE

Constant EXAMPLE_SOURCE 

Source
pub const EXAMPLE_SOURCE: &str = r#"context wire.sample

type Qty = Int where NonNegative

type Shape =
  | Circle(radius: Float)
  | Dot

type Line = {
  sku: String,
  qty: Int where Positive,
  wait: Duration,
  delay: Option[Duration],
  at: Instant,
  blob: Bytes,
  note: Option[String],
  tags: List[String],
  stock: Map[String, Int],
  rush: Bool,
}

service quote {
  on call(line: Line, size: Qty) -> Effect[Result[Shape, String]] {
    Ok(Dot)
  }
}

type Tagged[T] = {
  n: Int where Positive,
  v: T,
}

service who {
  on call(t: Tagged[String]) -> Effect[Result[String, String]] by c: Caller {
    Ok(c.identity)
  }
}

service ping {
  on call() -> Effect[Result[(), String]] {
    Ok(())
  }
}

actor Legacy { auth = Foreign(secret = "LEGACY_CALL_KEY") }

service legacy {
  on call(n: Int) -> Effect[Result[Int, String]] by Legacy {
    Ok(n)
  }
}
"#;
Expand description

The context the page’s examples and worked hash are computed on.