#[allow(unused_imports)]
use async_trait::async_trait;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[allow(unused_imports)]
use std::{borrow::Borrow, borrow::Cow, io::Write, string::ToString};
#[allow(unused_imports)]
use wasmbus_rpc::{
cbor::*,
common::{
deserialize, message_format, serialize, Context, Message, MessageDispatch, MessageFormat,
SendOpts, Transport,
},
error::{RpcError, RpcResult},
Timestamp,
};
#[allow(dead_code)]
pub const SMITHY_VERSION: &str = "1.0";
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct ActorAuctionAck {
#[serde(rename = "actorRef")]
#[serde(default)]
pub actor_ref: String,
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_actor_auction_ack<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ActorAuctionAck,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(2)?;
e.str("actorRef")?;
e.str(&val.actor_ref)?;
e.str("hostId")?;
e.str(&val.host_id)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_actor_auction_ack(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ActorAuctionAck, RpcError> {
let __result = {
let mut actor_ref: Option<String> = None;
let mut host_id: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct ActorAuctionAck, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => actor_ref = Some(d.str()?.to_string()),
1 => host_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"actorRef" => actor_ref = Some(d.str()?.to_string()),
"hostId" => host_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
ActorAuctionAck {
actor_ref: if let Some(__x) = actor_ref {
__x
} else {
return Err(RpcError::Deser(
"missing field ActorAuctionAck.actor_ref (#0)".to_string(),
));
},
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field ActorAuctionAck.host_id (#1)".to_string(),
));
},
}
};
Ok(__result)
}
pub type ActorAuctionAcks = Vec<ActorAuctionAck>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_actor_auction_acks<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ActorAuctionAcks,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.array(val.len() as u64)?;
for item in val.iter() {
encode_actor_auction_ack(e, item)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_actor_auction_acks(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ActorAuctionAcks, RpcError> {
let __result = {
if let Some(n) = d.array()? {
let mut arr: Vec<ActorAuctionAck> = Vec::with_capacity(n as usize);
for _ in 0..(n as usize) {
arr.push(decode_actor_auction_ack(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ActorAuctionAck': {}",
e
)
})?)
}
arr
} else {
let mut arr: Vec<ActorAuctionAck> = Vec::new();
loop {
match d.datatype() {
Err(_) => break,
Ok(wasmbus_rpc::cbor::Type::Break) => break,
Ok(_) => arr.push(decode_actor_auction_ack(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ActorAuctionAck': {}",
e
)
})?),
}
}
arr
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct ActorAuctionRequest {
#[serde(rename = "actorRef")]
#[serde(default)]
pub actor_ref: String,
pub constraints: ConstraintMap,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_actor_auction_request<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ActorAuctionRequest,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(3)?;
e.str("actorRef")?;
e.str(&val.actor_ref)?;
e.str("constraints")?;
encode_constraint_map(e, &val.constraints)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_actor_auction_request(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ActorAuctionRequest, RpcError> {
let __result = {
let mut actor_ref: Option<String> = None;
let mut constraints: Option<ConstraintMap> = None;
let mut lattice_id: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct ActorAuctionRequest, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => actor_ref = Some(d.str()?.to_string()),
1 => {
constraints = Some(decode_constraint_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ConstraintMap': {}",
e
)
})?)
}
2 => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"actorRef" => actor_ref = Some(d.str()?.to_string()),
"constraints" => {
constraints = Some(decode_constraint_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ConstraintMap': {}",
e
)
})?)
}
"latticeId" => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
ActorAuctionRequest {
actor_ref: if let Some(__x) = actor_ref {
__x
} else {
return Err(RpcError::Deser(
"missing field ActorAuctionRequest.actor_ref (#0)".to_string(),
));
},
constraints: if let Some(__x) = constraints {
__x
} else {
return Err(RpcError::Deser(
"missing field ActorAuctionRequest.constraints (#1)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field ActorAuctionRequest.lattice_id (#2)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct ActorDescription {
#[serde(default)]
pub id: String,
#[serde(rename = "imageRef")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub image_ref: Option<String>,
pub instances: ActorInstances,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_actor_description<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ActorDescription,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(4)?;
e.str("id")?;
e.str(&val.id)?;
if let Some(val) = val.image_ref.as_ref() {
e.str("imageRef")?;
e.str(val)?;
} else {
e.null()?;
}
e.str("instances")?;
encode_actor_instances(e, &val.instances)?;
if let Some(val) = val.name.as_ref() {
e.str("name")?;
e.str(val)?;
} else {
e.null()?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_actor_description(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ActorDescription, RpcError> {
let __result = {
let mut id: Option<String> = None;
let mut image_ref: Option<Option<String>> = Some(None);
let mut instances: Option<ActorInstances> = None;
let mut name: Option<Option<String>> = Some(None);
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct ActorDescription, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => id = Some(d.str()?.to_string()),
1 => {
image_ref = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
2 => {
instances = Some(decode_actor_instances(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ActorInstances': {}",
e
)
})?)
}
3 => {
name = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"id" => id = Some(d.str()?.to_string()),
"imageRef" => {
image_ref = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"instances" => {
instances = Some(decode_actor_instances(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ActorInstances': {}",
e
)
})?)
}
"name" => {
name = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
_ => d.skip()?,
}
}
}
ActorDescription {
id: if let Some(__x) = id {
__x
} else {
return Err(RpcError::Deser(
"missing field ActorDescription.id (#0)".to_string(),
));
},
image_ref: image_ref.unwrap(),
instances: if let Some(__x) = instances {
__x
} else {
return Err(RpcError::Deser(
"missing field ActorDescription.instances (#2)".to_string(),
));
},
name: name.unwrap(),
}
};
Ok(__result)
}
pub type ActorDescriptions = Vec<ActorDescription>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_actor_descriptions<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ActorDescriptions,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.array(val.len() as u64)?;
for item in val.iter() {
encode_actor_description(e, item)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_actor_descriptions(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ActorDescriptions, RpcError> {
let __result = {
if let Some(n) = d.array()? {
let mut arr: Vec<ActorDescription> = Vec::with_capacity(n as usize);
for _ in 0..(n as usize) {
arr.push(decode_actor_description(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ActorDescription': {}",
e
)
})?)
}
arr
} else {
let mut arr: Vec<ActorDescription> = Vec::new();
loop {
match d.datatype() {
Err(_) => break,
Ok(wasmbus_rpc::cbor::Type::Break) => break,
Ok(_) => arr.push(decode_actor_description(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ActorDescription': {}",
e
)
})?),
}
}
arr
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct ActorInstance {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotations: Option<AnnotationMap>,
#[serde(rename = "instanceId")]
#[serde(default)]
pub instance_id: String,
#[serde(default)]
pub revision: i32,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_actor_instance<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ActorInstance,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(3)?;
if let Some(val) = val.annotations.as_ref() {
e.str("annotations")?;
encode_annotation_map(e, val)?;
} else {
e.null()?;
}
e.str("instanceId")?;
e.str(&val.instance_id)?;
e.str("revision")?;
e.i32(val.revision)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_actor_instance(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ActorInstance, RpcError> {
let __result = {
let mut annotations: Option<Option<AnnotationMap>> = Some(None);
let mut instance_id: Option<String> = None;
let mut revision: Option<i32> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct ActorInstance, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
1 => instance_id = Some(d.str()?.to_string()),
2 => revision = Some(d.i32()?),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"annotations" => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
"instanceId" => instance_id = Some(d.str()?.to_string()),
"revision" => revision = Some(d.i32()?),
_ => d.skip()?,
}
}
}
ActorInstance {
annotations: annotations.unwrap(),
instance_id: if let Some(__x) = instance_id {
__x
} else {
return Err(RpcError::Deser(
"missing field ActorInstance.instance_id (#1)".to_string(),
));
},
revision: if let Some(__x) = revision {
__x
} else {
return Err(RpcError::Deser(
"missing field ActorInstance.revision (#2)".to_string(),
));
},
}
};
Ok(__result)
}
pub type ActorInstances = Vec<ActorInstance>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_actor_instances<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ActorInstances,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.array(val.len() as u64)?;
for item in val.iter() {
encode_actor_instance(e, item)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_actor_instances(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ActorInstances, RpcError> {
let __result = {
if let Some(n) = d.array()? {
let mut arr: Vec<ActorInstance> = Vec::with_capacity(n as usize);
for _ in 0..(n as usize) {
arr.push(decode_actor_instance(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ActorInstance': {}",
e
)
})?)
}
arr
} else {
let mut arr: Vec<ActorInstance> = Vec::new();
loop {
match d.datatype() {
Err(_) => break,
Ok(wasmbus_rpc::cbor::Type::Break) => break,
Ok(_) => arr.push(decode_actor_instance(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ActorInstance': {}",
e
)
})?),
}
}
arr
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct AdvertiseLinkRequest {
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
pub link: wasmbus_rpc::core::LinkDefinition,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_advertise_link_request<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &AdvertiseLinkRequest,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(2)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
e.str("link")?;
wasmbus_rpc::core::encode_link_definition(e, &val.link)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_advertise_link_request(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<AdvertiseLinkRequest, RpcError> {
let __result = {
let mut lattice_id: Option<String> = None;
let mut link: Option<wasmbus_rpc::core::LinkDefinition> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct AdvertiseLinkRequest, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => lattice_id = Some(d.str()?.to_string()),
1 => {
link = Some(wasmbus_rpc::core::decode_link_definition(d).map_err(|e| {
format!("decoding 'org.wasmcloud.core#LinkDefinition': {}", e)
})?)
}
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"latticeId" => lattice_id = Some(d.str()?.to_string()),
"link" => {
link = Some(wasmbus_rpc::core::decode_link_definition(d).map_err(|e| {
format!("decoding 'org.wasmcloud.core#LinkDefinition': {}", e)
})?)
}
_ => d.skip()?,
}
}
}
AdvertiseLinkRequest {
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field AdvertiseLinkRequest.lattice_id (#0)".to_string(),
));
},
link: if let Some(__x) = link {
__x
} else {
return Err(RpcError::Deser(
"missing field AdvertiseLinkRequest.link (#1)".to_string(),
));
},
}
};
Ok(__result)
}
pub type AnnotationMap = std::collections::HashMap<String, String>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_annotation_map<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &AnnotationMap,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(val.len() as u64)?;
for (k, v) in val {
e.str(k)?;
e.str(v)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_annotation_map(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<AnnotationMap, RpcError> {
let __result = {
{
let map_len = d.fixed_map()? as usize;
let mut m: std::collections::HashMap<String, String> =
std::collections::HashMap::with_capacity(map_len);
for _ in 0..map_len {
let k = d.str()?.to_string();
let v = d.str()?.to_string();
m.insert(k, v);
}
m
}
};
Ok(__result)
}
pub type ConfigurationString = String;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_configuration_string<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ConfigurationString,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.str(val)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_configuration_string(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ConfigurationString, RpcError> {
let __result = { d.str()?.to_string() };
Ok(__result)
}
pub type ConstraintMap = std::collections::HashMap<String, String>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_constraint_map<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ConstraintMap,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(val.len() as u64)?;
for (k, v) in val {
e.str(k)?;
e.str(v)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_constraint_map(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ConstraintMap, RpcError> {
let __result = {
{
let map_len = d.fixed_map()? as usize;
let mut m: std::collections::HashMap<String, String> =
std::collections::HashMap::with_capacity(map_len);
for _ in 0..map_len {
let k = d.str()?.to_string();
let v = d.str()?.to_string();
m.insert(k, v);
}
m
}
};
Ok(__result)
}
pub type CtlKVList = Vec<KeyValueMap>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_ctl_kv_list<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &CtlKVList,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.array(val.len() as u64)?;
for item in val.iter() {
encode_key_value_map(e, item)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_ctl_kv_list(d: &mut wasmbus_rpc::cbor::Decoder<'_>) -> Result<CtlKVList, RpcError> {
let __result = {
if let Some(n) = d.array()? {
let mut arr: Vec<KeyValueMap> = Vec::with_capacity(n as usize);
for _ in 0..(n as usize) {
arr.push(decode_key_value_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#KeyValueMap': {}",
e
)
})?)
}
arr
} else {
let mut arr: Vec<KeyValueMap> = Vec::new();
loop {
match d.datatype() {
Err(_) => break,
Ok(wasmbus_rpc::cbor::Type::Break) => break,
Ok(_) => arr.push(decode_key_value_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#KeyValueMap': {}",
e
)
})?),
}
}
arr
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct CtlOperationAck {
#[serde(default)]
pub accepted: bool,
#[serde(default)]
pub error: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_ctl_operation_ack<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &CtlOperationAck,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(2)?;
e.str("accepted")?;
e.bool(val.accepted)?;
e.str("error")?;
e.str(&val.error)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_ctl_operation_ack(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<CtlOperationAck, RpcError> {
let __result = {
let mut accepted: Option<bool> = None;
let mut error: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct CtlOperationAck, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => accepted = Some(d.bool()?),
1 => error = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"accepted" => accepted = Some(d.bool()?),
"error" => error = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
CtlOperationAck {
accepted: if let Some(__x) = accepted {
__x
} else {
return Err(RpcError::Deser(
"missing field CtlOperationAck.accepted (#0)".to_string(),
));
},
error: if let Some(__x) = error {
__x
} else {
return Err(RpcError::Deser(
"missing field CtlOperationAck.error (#1)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct GetClaimsRequest {
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_get_claims_request<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &GetClaimsRequest,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(1)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_get_claims_request(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<GetClaimsRequest, RpcError> {
let __result = {
let mut lattice_id: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct GetClaimsRequest, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"latticeId" => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
GetClaimsRequest {
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field GetClaimsRequest.lattice_id (#0)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct GetClaimsResponse {
pub claims: CtlKVList,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_get_claims_response<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &GetClaimsResponse,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(1)?;
e.str("claims")?;
encode_ctl_kv_list(e, &val.claims)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_get_claims_response(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<GetClaimsResponse, RpcError> {
let __result = {
let mut claims: Option<CtlKVList> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct GetClaimsResponse, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
claims = Some(decode_ctl_kv_list(d).map_err(|e| {
format!("decoding 'org.wasmcloud.lattice.control#CtlKVList': {}", e)
})?)
}
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"claims" => {
claims = Some(decode_ctl_kv_list(d).map_err(|e| {
format!("decoding 'org.wasmcloud.lattice.control#CtlKVList': {}", e)
})?)
}
_ => d.skip()?,
}
}
}
GetClaimsResponse {
claims: if let Some(__x) = claims {
__x
} else {
return Err(RpcError::Deser(
"missing field GetClaimsResponse.claims (#0)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct GetHostInventoryRequest {
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_get_host_inventory_request<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &GetHostInventoryRequest,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(2)?;
e.str("hostId")?;
e.str(&val.host_id)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_get_host_inventory_request(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<GetHostInventoryRequest, RpcError> {
let __result = {
let mut host_id: Option<String> = None;
let mut lattice_id: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct GetHostInventoryRequest, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => host_id = Some(d.str()?.to_string()),
1 => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"hostId" => host_id = Some(d.str()?.to_string()),
"latticeId" => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
GetHostInventoryRequest {
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field GetHostInventoryRequest.host_id (#0)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field GetHostInventoryRequest.lattice_id (#1)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct GetHostsRequest {
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_get_hosts_request<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &GetHostsRequest,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(1)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_get_hosts_request(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<GetHostsRequest, RpcError> {
let __result = {
let mut lattice_id: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct GetHostsRequest, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"latticeId" => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
GetHostsRequest {
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field GetHostsRequest.lattice_id (#0)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct Host {
#[serde(rename = "clusterIssuers")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cluster_issuers: Option<String>,
#[serde(rename = "ctlHost")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ctl_host: Option<String>,
#[serde(default)]
pub id: String,
#[serde(rename = "jsDomain")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub js_domain: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub labels: Option<KeyValueMap>,
#[serde(rename = "latticePrefix")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub lattice_prefix: Option<String>,
#[serde(rename = "provRpcHost")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub prov_rpc_host: Option<String>,
#[serde(rename = "rpcHost")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub rpc_host: Option<String>,
#[serde(rename = "uptimeHuman")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub uptime_human: Option<String>,
#[serde(rename = "uptimeSeconds")]
#[serde(default)]
pub uptime_seconds: u64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_host<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &Host,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(11)?;
if let Some(val) = val.cluster_issuers.as_ref() {
e.str("clusterIssuers")?;
e.str(val)?;
} else {
e.null()?;
}
if let Some(val) = val.ctl_host.as_ref() {
e.str("ctlHost")?;
e.str(val)?;
} else {
e.null()?;
}
e.str("id")?;
e.str(&val.id)?;
if let Some(val) = val.js_domain.as_ref() {
e.str("jsDomain")?;
e.str(val)?;
} else {
e.null()?;
}
if let Some(val) = val.labels.as_ref() {
e.str("labels")?;
encode_key_value_map(e, val)?;
} else {
e.null()?;
}
if let Some(val) = val.lattice_prefix.as_ref() {
e.str("latticePrefix")?;
e.str(val)?;
} else {
e.null()?;
}
if let Some(val) = val.prov_rpc_host.as_ref() {
e.str("provRpcHost")?;
e.str(val)?;
} else {
e.null()?;
}
if let Some(val) = val.rpc_host.as_ref() {
e.str("rpcHost")?;
e.str(val)?;
} else {
e.null()?;
}
if let Some(val) = val.uptime_human.as_ref() {
e.str("uptimeHuman")?;
e.str(val)?;
} else {
e.null()?;
}
e.str("uptimeSeconds")?;
e.u64(val.uptime_seconds)?;
if let Some(val) = val.version.as_ref() {
e.str("version")?;
e.str(val)?;
} else {
e.null()?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_host(d: &mut wasmbus_rpc::cbor::Decoder<'_>) -> Result<Host, RpcError> {
let __result = {
let mut cluster_issuers: Option<Option<String>> = Some(None);
let mut ctl_host: Option<Option<String>> = Some(None);
let mut id: Option<String> = None;
let mut js_domain: Option<Option<String>> = Some(None);
let mut labels: Option<Option<KeyValueMap>> = Some(None);
let mut lattice_prefix: Option<Option<String>> = Some(None);
let mut prov_rpc_host: Option<Option<String>> = Some(None);
let mut rpc_host: Option<Option<String>> = Some(None);
let mut uptime_human: Option<Option<String>> = Some(None);
let mut uptime_seconds: Option<u64> = None;
let mut version: Option<Option<String>> = Some(None);
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct Host, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
cluster_issuers = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
1 => {
ctl_host = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
2 => id = Some(d.str()?.to_string()),
3 => {
js_domain = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
4 => {
labels = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_key_value_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#KeyValueMap': {}",
e
)
})?))
}
}
5 => {
lattice_prefix = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
6 => {
prov_rpc_host = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
7 => {
rpc_host = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
8 => {
uptime_human = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
9 => uptime_seconds = Some(d.u64()?),
10 => {
version = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"clusterIssuers" => {
cluster_issuers = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"ctlHost" => {
ctl_host = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"id" => id = Some(d.str()?.to_string()),
"jsDomain" => {
js_domain = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"labels" => {
labels = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_key_value_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#KeyValueMap': {}",
e
)
})?))
}
}
"latticePrefix" => {
lattice_prefix = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"provRpcHost" => {
prov_rpc_host = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"rpcHost" => {
rpc_host = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"uptimeHuman" => {
uptime_human = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"uptimeSeconds" => uptime_seconds = Some(d.u64()?),
"version" => {
version = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
_ => d.skip()?,
}
}
}
Host {
cluster_issuers: cluster_issuers.unwrap(),
ctl_host: ctl_host.unwrap(),
id: if let Some(__x) = id {
__x
} else {
return Err(RpcError::Deser("missing field Host.id (#2)".to_string()));
},
js_domain: js_domain.unwrap(),
labels: labels.unwrap(),
lattice_prefix: lattice_prefix.unwrap(),
prov_rpc_host: prov_rpc_host.unwrap(),
rpc_host: rpc_host.unwrap(),
uptime_human: uptime_human.unwrap(),
uptime_seconds: if let Some(__x) = uptime_seconds {
__x
} else {
return Err(RpcError::Deser(
"missing field Host.uptime_seconds (#9)".to_string(),
));
},
version: version.unwrap(),
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct HostInventory {
pub actors: ActorDescriptions,
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
pub labels: LabelsMap,
pub providers: ProviderDescriptions,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_host_inventory<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &HostInventory,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(4)?;
e.str("actors")?;
encode_actor_descriptions(e, &val.actors)?;
e.str("hostId")?;
e.str(&val.host_id)?;
e.str("labels")?;
encode_labels_map(e, &val.labels)?;
e.str("providers")?;
encode_provider_descriptions(e, &val.providers)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_host_inventory(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<HostInventory, RpcError> {
let __result = {
let mut actors: Option<ActorDescriptions> = None;
let mut host_id: Option<String> = None;
let mut labels: Option<LabelsMap> = None;
let mut providers: Option<ProviderDescriptions> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct HostInventory, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
actors = Some(decode_actor_descriptions(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ActorDescriptions': {}",
e
)
})?)
}
1 => host_id = Some(d.str()?.to_string()),
2 => {
labels = Some(decode_labels_map(d).map_err(|e| {
format!("decoding 'org.wasmcloud.lattice.control#LabelsMap': {}", e)
})?)
}
3 => {
providers = Some(decode_provider_descriptions(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ProviderDescriptions': {}",
e
)
})?)
}
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"actors" => {
actors = Some(decode_actor_descriptions(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ActorDescriptions': {}",
e
)
})?)
}
"hostId" => host_id = Some(d.str()?.to_string()),
"labels" => {
labels = Some(decode_labels_map(d).map_err(|e| {
format!("decoding 'org.wasmcloud.lattice.control#LabelsMap': {}", e)
})?)
}
"providers" => {
providers = Some(decode_provider_descriptions(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ProviderDescriptions': {}",
e
)
})?)
}
_ => d.skip()?,
}
}
}
HostInventory {
actors: if let Some(__x) = actors {
__x
} else {
return Err(RpcError::Deser(
"missing field HostInventory.actors (#0)".to_string(),
));
},
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field HostInventory.host_id (#1)".to_string(),
));
},
labels: if let Some(__x) = labels {
__x
} else {
return Err(RpcError::Deser(
"missing field HostInventory.labels (#2)".to_string(),
));
},
providers: if let Some(__x) = providers {
__x
} else {
return Err(RpcError::Deser(
"missing field HostInventory.providers (#3)".to_string(),
));
},
}
};
Ok(__result)
}
pub type Hosts = Vec<Host>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_hosts<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &Hosts,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.array(val.len() as u64)?;
for item in val.iter() {
encode_host(e, item)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_hosts(d: &mut wasmbus_rpc::cbor::Decoder<'_>) -> Result<Hosts, RpcError> {
let __result =
{
if let Some(n) = d.array()? {
let mut arr: Vec<Host> = Vec::with_capacity(n as usize);
for _ in 0..(n as usize) {
arr.push(decode_host(d).map_err(|e| {
format!("decoding 'org.wasmcloud.lattice.control#Host': {}", e)
})?)
}
arr
} else {
let mut arr: Vec<Host> = Vec::new();
loop {
match d.datatype() {
Err(_) => break,
Ok(wasmbus_rpc::cbor::Type::Break) => break,
Ok(_) => arr.push(decode_host(d).map_err(|e| {
format!("decoding 'org.wasmcloud.lattice.control#Host': {}", e)
})?),
}
}
arr
}
};
Ok(__result)
}
pub type KeyValueMap = std::collections::HashMap<String, String>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_key_value_map<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &KeyValueMap,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(val.len() as u64)?;
for (k, v) in val {
e.str(k)?;
e.str(v)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_key_value_map(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<KeyValueMap, RpcError> {
let __result = {
{
let map_len = d.fixed_map()? as usize;
let mut m: std::collections::HashMap<String, String> =
std::collections::HashMap::with_capacity(map_len);
for _ in 0..map_len {
let k = d.str()?.to_string();
let v = d.str()?.to_string();
m.insert(k, v);
}
m
}
};
Ok(__result)
}
pub type LabelsMap = std::collections::HashMap<String, String>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_labels_map<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &LabelsMap,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(val.len() as u64)?;
for (k, v) in val {
e.str(k)?;
e.str(v)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_labels_map(d: &mut wasmbus_rpc::cbor::Decoder<'_>) -> Result<LabelsMap, RpcError> {
let __result = {
{
let map_len = d.fixed_map()? as usize;
let mut m: std::collections::HashMap<String, String> =
std::collections::HashMap::with_capacity(map_len);
for _ in 0..map_len {
let k = d.str()?.to_string();
let v = d.str()?.to_string();
m.insert(k, v);
}
m
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct LinkDefinitionList {
pub links: wasmbus_rpc::core::ActorLinks,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_link_definition_list<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &LinkDefinitionList,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(1)?;
e.str("links")?;
wasmbus_rpc::core::encode_actor_links(e, &val.links)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_link_definition_list(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<LinkDefinitionList, RpcError> {
let __result = {
let mut links: Option<wasmbus_rpc::core::ActorLinks> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct LinkDefinitionList, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
links = Some(wasmbus_rpc::core::decode_actor_links(d).map_err(|e| {
format!("decoding 'org.wasmcloud.core#ActorLinks': {}", e)
})?)
}
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"links" => {
links = Some(wasmbus_rpc::core::decode_actor_links(d).map_err(|e| {
format!("decoding 'org.wasmcloud.core#ActorLinks': {}", e)
})?)
}
_ => d.skip()?,
}
}
}
LinkDefinitionList {
links: if let Some(__x) = links {
__x
} else {
return Err(RpcError::Deser(
"missing field LinkDefinitionList.links (#0)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct ProviderAuctionAck {
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
#[serde(rename = "linkName")]
#[serde(default)]
pub link_name: String,
#[serde(rename = "providerRef")]
#[serde(default)]
pub provider_ref: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_provider_auction_ack<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ProviderAuctionAck,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(3)?;
e.str("hostId")?;
e.str(&val.host_id)?;
e.str("linkName")?;
e.str(&val.link_name)?;
e.str("providerRef")?;
e.str(&val.provider_ref)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_provider_auction_ack(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ProviderAuctionAck, RpcError> {
let __result = {
let mut host_id: Option<String> = None;
let mut link_name: Option<String> = None;
let mut provider_ref: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct ProviderAuctionAck, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => host_id = Some(d.str()?.to_string()),
1 => link_name = Some(d.str()?.to_string()),
2 => provider_ref = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"hostId" => host_id = Some(d.str()?.to_string()),
"linkName" => link_name = Some(d.str()?.to_string()),
"providerRef" => provider_ref = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
ProviderAuctionAck {
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field ProviderAuctionAck.host_id (#0)".to_string(),
));
},
link_name: if let Some(__x) = link_name {
__x
} else {
return Err(RpcError::Deser(
"missing field ProviderAuctionAck.link_name (#1)".to_string(),
));
},
provider_ref: if let Some(__x) = provider_ref {
__x
} else {
return Err(RpcError::Deser(
"missing field ProviderAuctionAck.provider_ref (#2)".to_string(),
));
},
}
};
Ok(__result)
}
pub type ProviderAuctionAcks = Vec<ProviderAuctionAck>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_provider_auction_acks<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ProviderAuctionAcks,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.array(val.len() as u64)?;
for item in val.iter() {
encode_provider_auction_ack(e, item)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_provider_auction_acks(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ProviderAuctionAcks, RpcError> {
let __result = {
if let Some(n) = d.array()? {
let mut arr: Vec<ProviderAuctionAck> = Vec::with_capacity(n as usize);
for _ in 0..(n as usize) {
arr.push(decode_provider_auction_ack(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ProviderAuctionAck': {}",
e
)
})?)
}
arr
} else {
let mut arr: Vec<ProviderAuctionAck> = Vec::new();
loop {
match d.datatype() {
Err(_) => break,
Ok(wasmbus_rpc::cbor::Type::Break) => break,
Ok(_) => arr.push(decode_provider_auction_ack(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ProviderAuctionAck': {}",
e
)
})?),
}
}
arr
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct ProviderAuctionRequest {
pub constraints: ConstraintMap,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
#[serde(rename = "linkName")]
#[serde(default)]
pub link_name: String,
#[serde(rename = "providerRef")]
#[serde(default)]
pub provider_ref: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_provider_auction_request<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ProviderAuctionRequest,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(4)?;
e.str("constraints")?;
encode_constraint_map(e, &val.constraints)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
e.str("linkName")?;
e.str(&val.link_name)?;
e.str("providerRef")?;
e.str(&val.provider_ref)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_provider_auction_request(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ProviderAuctionRequest, RpcError> {
let __result = {
let mut constraints: Option<ConstraintMap> = None;
let mut lattice_id: Option<String> = None;
let mut link_name: Option<String> = None;
let mut provider_ref: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct ProviderAuctionRequest, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
constraints = Some(decode_constraint_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ConstraintMap': {}",
e
)
})?)
}
1 => lattice_id = Some(d.str()?.to_string()),
2 => link_name = Some(d.str()?.to_string()),
3 => provider_ref = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"constraints" => {
constraints = Some(decode_constraint_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ConstraintMap': {}",
e
)
})?)
}
"latticeId" => lattice_id = Some(d.str()?.to_string()),
"linkName" => link_name = Some(d.str()?.to_string()),
"providerRef" => provider_ref = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
ProviderAuctionRequest {
constraints: if let Some(__x) = constraints {
__x
} else {
return Err(RpcError::Deser(
"missing field ProviderAuctionRequest.constraints (#0)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field ProviderAuctionRequest.lattice_id (#1)".to_string(),
));
},
link_name: if let Some(__x) = link_name {
__x
} else {
return Err(RpcError::Deser(
"missing field ProviderAuctionRequest.link_name (#2)".to_string(),
));
},
provider_ref: if let Some(__x) = provider_ref {
__x
} else {
return Err(RpcError::Deser(
"missing field ProviderAuctionRequest.provider_ref (#3)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct ProviderDescription {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotations: Option<AnnotationMap>,
#[serde(default)]
pub id: String,
#[serde(rename = "imageRef")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub image_ref: Option<String>,
#[serde(rename = "linkName")]
#[serde(default)]
pub link_name: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(default)]
pub revision: i32,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_provider_description<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ProviderDescription,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(6)?;
if let Some(val) = val.annotations.as_ref() {
e.str("annotations")?;
encode_annotation_map(e, val)?;
} else {
e.null()?;
}
e.str("id")?;
e.str(&val.id)?;
if let Some(val) = val.image_ref.as_ref() {
e.str("imageRef")?;
e.str(val)?;
} else {
e.null()?;
}
e.str("linkName")?;
e.str(&val.link_name)?;
if let Some(val) = val.name.as_ref() {
e.str("name")?;
e.str(val)?;
} else {
e.null()?;
}
e.str("revision")?;
e.i32(val.revision)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_provider_description(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ProviderDescription, RpcError> {
let __result = {
let mut annotations: Option<Option<AnnotationMap>> = Some(None);
let mut id: Option<String> = None;
let mut image_ref: Option<Option<String>> = Some(None);
let mut link_name: Option<String> = None;
let mut name: Option<Option<String>> = Some(None);
let mut revision: Option<i32> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct ProviderDescription, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
1 => id = Some(d.str()?.to_string()),
2 => {
image_ref = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
3 => link_name = Some(d.str()?.to_string()),
4 => {
name = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
5 => revision = Some(d.i32()?),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"annotations" => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
"id" => id = Some(d.str()?.to_string()),
"imageRef" => {
image_ref = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"linkName" => link_name = Some(d.str()?.to_string()),
"name" => {
name = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"revision" => revision = Some(d.i32()?),
_ => d.skip()?,
}
}
}
ProviderDescription {
annotations: annotations.unwrap(),
id: if let Some(__x) = id {
__x
} else {
return Err(RpcError::Deser(
"missing field ProviderDescription.id (#1)".to_string(),
));
},
image_ref: image_ref.unwrap(),
link_name: if let Some(__x) = link_name {
__x
} else {
return Err(RpcError::Deser(
"missing field ProviderDescription.link_name (#3)".to_string(),
));
},
name: name.unwrap(),
revision: if let Some(__x) = revision {
__x
} else {
return Err(RpcError::Deser(
"missing field ProviderDescription.revision (#5)".to_string(),
));
},
}
};
Ok(__result)
}
pub type ProviderDescriptions = Vec<ProviderDescription>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_provider_descriptions<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ProviderDescriptions,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.array(val.len() as u64)?;
for item in val.iter() {
encode_provider_description(e, item)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_provider_descriptions(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ProviderDescriptions, RpcError> {
let __result = {
if let Some(n) = d.array()? {
let mut arr: Vec<ProviderDescription> = Vec::with_capacity(n as usize);
for _ in 0..(n as usize) {
arr.push(decode_provider_description(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ProviderDescription': {}",
e
)
})?)
}
arr
} else {
let mut arr: Vec<ProviderDescription> = Vec::new();
loop {
match d.datatype() {
Err(_) => break,
Ok(wasmbus_rpc::cbor::Type::Break) => break,
Ok(_) => arr.push(decode_provider_description(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#ProviderDescription': {}",
e
)
})?),
}
}
arr
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct RegistryCredential {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub password: Option<String>,
#[serde(rename = "registryType")]
#[serde(default)]
pub registry_type: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub token: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_registry_credential<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &RegistryCredential,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(4)?;
if let Some(val) = val.password.as_ref() {
e.str("password")?;
e.str(val)?;
} else {
e.null()?;
}
e.str("registryType")?;
e.str(&val.registry_type)?;
if let Some(val) = val.token.as_ref() {
e.str("token")?;
e.str(val)?;
} else {
e.null()?;
}
if let Some(val) = val.username.as_ref() {
e.str("username")?;
e.str(val)?;
} else {
e.null()?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_registry_credential(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<RegistryCredential, RpcError> {
let __result = {
let mut password: Option<Option<String>> = Some(None);
let mut registry_type: Option<String> = None;
let mut token: Option<Option<String>> = Some(None);
let mut username: Option<Option<String>> = Some(None);
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct RegistryCredential, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
password = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
1 => registry_type = Some(d.str()?.to_string()),
2 => {
token = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
3 => {
username = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"password" => {
password = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"registryType" => registry_type = Some(d.str()?.to_string()),
"token" => {
token = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"username" => {
username = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
_ => d.skip()?,
}
}
}
RegistryCredential {
password: password.unwrap(),
registry_type: if let Some(__x) = registry_type {
__x
} else {
return Err(RpcError::Deser(
"missing field RegistryCredential.registry_type (#1)".to_string(),
));
},
token: token.unwrap(),
username: username.unwrap(),
}
};
Ok(__result)
}
pub type RegistryCredentialMap = std::collections::HashMap<String, RegistryCredential>;
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_registry_credential_map<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &RegistryCredentialMap,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(val.len() as u64)?;
for (k, v) in val {
e.str(k)?;
encode_registry_credential(e, v)?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_registry_credential_map(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<RegistryCredentialMap, RpcError> {
let __result = {
{
let map_len = d.fixed_map()? as usize;
let mut m: std::collections::HashMap<String, RegistryCredential> =
std::collections::HashMap::with_capacity(map_len);
for _ in 0..map_len {
let k = d.str()?.to_string();
let v = decode_registry_credential(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#RegistryCredential': {}",
e
)
})?;
m.insert(k, v);
}
m
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct RemoveLinkDefinitionRequest {
#[serde(rename = "actorId")]
#[serde(default)]
pub actor_id: String,
#[serde(rename = "contractId")]
#[serde(default)]
pub contract_id: String,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
#[serde(rename = "linkName")]
#[serde(default)]
pub link_name: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_remove_link_definition_request<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &RemoveLinkDefinitionRequest,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(4)?;
e.str("actorId")?;
e.str(&val.actor_id)?;
e.str("contractId")?;
e.str(&val.contract_id)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
e.str("linkName")?;
e.str(&val.link_name)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_remove_link_definition_request(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<RemoveLinkDefinitionRequest, RpcError> {
let __result = {
let mut actor_id: Option<String> = None;
let mut contract_id: Option<String> = None;
let mut lattice_id: Option<String> = None;
let mut link_name: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct RemoveLinkDefinitionRequest, expected array or map"
.to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => actor_id = Some(d.str()?.to_string()),
1 => contract_id = Some(d.str()?.to_string()),
2 => lattice_id = Some(d.str()?.to_string()),
3 => link_name = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"actorId" => actor_id = Some(d.str()?.to_string()),
"contractId" => contract_id = Some(d.str()?.to_string()),
"latticeId" => lattice_id = Some(d.str()?.to_string()),
"linkName" => link_name = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
RemoveLinkDefinitionRequest {
actor_id: if let Some(__x) = actor_id {
__x
} else {
return Err(RpcError::Deser(
"missing field RemoveLinkDefinitionRequest.actor_id (#0)".to_string(),
));
},
contract_id: if let Some(__x) = contract_id {
__x
} else {
return Err(RpcError::Deser(
"missing field RemoveLinkDefinitionRequest.contract_id (#1)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field RemoveLinkDefinitionRequest.lattice_id (#2)".to_string(),
));
},
link_name: if let Some(__x) = link_name {
__x
} else {
return Err(RpcError::Deser(
"missing field RemoveLinkDefinitionRequest.link_name (#3)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct ScaleActorCommand {
#[serde(rename = "actorId")]
#[serde(default)]
pub actor_id: String,
#[serde(rename = "actorRef")]
#[serde(default)]
pub actor_ref: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotations: Option<AnnotationMap>,
#[serde(default)]
pub count: u16,
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_scale_actor_command<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &ScaleActorCommand,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(6)?;
e.str("actorId")?;
e.str(&val.actor_id)?;
e.str("actorRef")?;
e.str(&val.actor_ref)?;
if let Some(val) = val.annotations.as_ref() {
e.str("annotations")?;
encode_annotation_map(e, val)?;
} else {
e.null()?;
}
e.str("count")?;
e.u16(val.count)?;
e.str("hostId")?;
e.str(&val.host_id)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_scale_actor_command(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<ScaleActorCommand, RpcError> {
let __result = {
let mut actor_id: Option<String> = None;
let mut actor_ref: Option<String> = None;
let mut annotations: Option<Option<AnnotationMap>> = Some(None);
let mut count: Option<u16> = None;
let mut host_id: Option<String> = None;
let mut lattice_id: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct ScaleActorCommand, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => actor_id = Some(d.str()?.to_string()),
1 => actor_ref = Some(d.str()?.to_string()),
2 => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
3 => count = Some(d.u16()?),
4 => host_id = Some(d.str()?.to_string()),
5 => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"actorId" => actor_id = Some(d.str()?.to_string()),
"actorRef" => actor_ref = Some(d.str()?.to_string()),
"annotations" => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
"count" => count = Some(d.u16()?),
"hostId" => host_id = Some(d.str()?.to_string()),
"latticeId" => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
ScaleActorCommand {
actor_id: if let Some(__x) = actor_id {
__x
} else {
return Err(RpcError::Deser(
"missing field ScaleActorCommand.actor_id (#0)".to_string(),
));
},
actor_ref: if let Some(__x) = actor_ref {
__x
} else {
return Err(RpcError::Deser(
"missing field ScaleActorCommand.actor_ref (#1)".to_string(),
));
},
annotations: annotations.unwrap(),
count: if let Some(__x) = count {
__x
} else {
return Err(RpcError::Deser(
"missing field ScaleActorCommand.count (#3)".to_string(),
));
},
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field ScaleActorCommand.host_id (#4)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field ScaleActorCommand.lattice_id (#5)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct SetLatticeCredentialsRequest {
#[serde(rename = "jsDomain")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub js_domain: Option<String>,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
#[serde(rename = "natsUrl")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub nats_url: Option<String>,
#[serde(rename = "userJwt")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub user_jwt: Option<String>,
#[serde(rename = "userSeed")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub user_seed: Option<String>,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_set_lattice_credentials_request<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &SetLatticeCredentialsRequest,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(5)?;
if let Some(val) = val.js_domain.as_ref() {
e.str("jsDomain")?;
e.str(val)?;
} else {
e.null()?;
}
e.str("latticeId")?;
e.str(&val.lattice_id)?;
if let Some(val) = val.nats_url.as_ref() {
e.str("natsUrl")?;
e.str(val)?;
} else {
e.null()?;
}
if let Some(val) = val.user_jwt.as_ref() {
e.str("userJwt")?;
e.str(val)?;
} else {
e.null()?;
}
if let Some(val) = val.user_seed.as_ref() {
e.str("userSeed")?;
e.str(val)?;
} else {
e.null()?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_set_lattice_credentials_request(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<SetLatticeCredentialsRequest, RpcError> {
let __result = {
let mut js_domain: Option<Option<String>> = Some(None);
let mut lattice_id: Option<String> = None;
let mut nats_url: Option<Option<String>> = Some(None);
let mut user_jwt: Option<Option<String>> = Some(None);
let mut user_seed: Option<Option<String>> = Some(None);
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct SetLatticeCredentialsRequest, expected array or map"
.to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
js_domain = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
1 => lattice_id = Some(d.str()?.to_string()),
2 => {
nats_url = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
3 => {
user_jwt = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
4 => {
user_seed = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"jsDomain" => {
js_domain = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"latticeId" => lattice_id = Some(d.str()?.to_string()),
"natsUrl" => {
nats_url = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"userJwt" => {
user_jwt = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
"userSeed" => {
user_seed = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.str()?.to_string()))
}
}
_ => d.skip()?,
}
}
}
SetLatticeCredentialsRequest {
js_domain: js_domain.unwrap(),
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field SetLatticeCredentialsRequest.lattice_id (#1)".to_string(),
));
},
nats_url: nats_url.unwrap(),
user_jwt: user_jwt.unwrap(),
user_seed: user_seed.unwrap(),
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct SetRegistryCredentialsRequest {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub credentials: Option<RegistryCredentialMap>,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_set_registry_credentials_request<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &SetRegistryCredentialsRequest,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(2)?;
if let Some(val) = val.credentials.as_ref() {
e.str("credentials")?;
encode_registry_credential_map(e, val)?;
} else {
e.null()?;
}
e.str("latticeId")?;
e.str(&val.lattice_id)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_set_registry_credentials_request(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<SetRegistryCredentialsRequest, RpcError> {
let __result = {
let mut credentials: Option<Option<RegistryCredentialMap>> = Some(None);
let mut lattice_id: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct SetRegistryCredentialsRequest, expected array or map"
.to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
credentials = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some( decode_registry_credential_map(d).map_err(|e| format!("decoding 'org.wasmcloud.lattice.control#RegistryCredentialMap': {}", e))? ))
}
}
1 => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"credentials" => {
credentials = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some( decode_registry_credential_map(d).map_err(|e| format!("decoding 'org.wasmcloud.lattice.control#RegistryCredentialMap': {}", e))? ))
}
}
"latticeId" => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
SetRegistryCredentialsRequest {
credentials: credentials.unwrap(),
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field SetRegistryCredentialsRequest.lattice_id (#1)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct StartActorCommand {
#[serde(rename = "actorRef")]
#[serde(default)]
pub actor_ref: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotations: Option<AnnotationMap>,
#[serde(default)]
pub count: u16,
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_start_actor_command<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &StartActorCommand,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(5)?;
e.str("actorRef")?;
e.str(&val.actor_ref)?;
if let Some(val) = val.annotations.as_ref() {
e.str("annotations")?;
encode_annotation_map(e, val)?;
} else {
e.null()?;
}
e.str("count")?;
e.u16(val.count)?;
e.str("hostId")?;
e.str(&val.host_id)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_start_actor_command(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<StartActorCommand, RpcError> {
let __result = {
let mut actor_ref: Option<String> = None;
let mut annotations: Option<Option<AnnotationMap>> = Some(None);
let mut count: Option<u16> = None;
let mut host_id: Option<String> = None;
let mut lattice_id: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct StartActorCommand, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => actor_ref = Some(d.str()?.to_string()),
1 => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
2 => count = Some(d.u16()?),
3 => host_id = Some(d.str()?.to_string()),
4 => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"actorRef" => actor_ref = Some(d.str()?.to_string()),
"annotations" => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
"count" => count = Some(d.u16()?),
"hostId" => host_id = Some(d.str()?.to_string()),
"latticeId" => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
StartActorCommand {
actor_ref: if let Some(__x) = actor_ref {
__x
} else {
return Err(RpcError::Deser(
"missing field StartActorCommand.actor_ref (#0)".to_string(),
));
},
annotations: annotations.unwrap(),
count: if let Some(__x) = count {
__x
} else {
return Err(RpcError::Deser(
"missing field StartActorCommand.count (#2)".to_string(),
));
},
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StartActorCommand.host_id (#3)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StartActorCommand.lattice_id (#4)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct StartProviderCommand {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotations: Option<AnnotationMap>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub configuration: Option<ConfigurationString>,
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
#[serde(rename = "linkName")]
#[serde(default)]
pub link_name: String,
#[serde(rename = "providerRef")]
#[serde(default)]
pub provider_ref: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_start_provider_command<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &StartProviderCommand,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(6)?;
if let Some(val) = val.annotations.as_ref() {
e.str("annotations")?;
encode_annotation_map(e, val)?;
} else {
e.null()?;
}
if let Some(val) = val.configuration.as_ref() {
e.str("configuration")?;
encode_configuration_string(e, val)?;
} else {
e.null()?;
}
e.str("hostId")?;
e.str(&val.host_id)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
e.str("linkName")?;
e.str(&val.link_name)?;
e.str("providerRef")?;
e.str(&val.provider_ref)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_start_provider_command(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<StartProviderCommand, RpcError> {
let __result = {
let mut annotations: Option<Option<AnnotationMap>> = Some(None);
let mut configuration: Option<Option<ConfigurationString>> = Some(None);
let mut host_id: Option<String> = None;
let mut lattice_id: Option<String> = None;
let mut link_name: Option<String> = None;
let mut provider_ref: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct StartProviderCommand, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
1 => {
configuration = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some( decode_configuration_string(d).map_err(|e| format!("decoding 'org.wasmcloud.lattice.control#ConfigurationString': {}", e))? ))
}
}
2 => host_id = Some(d.str()?.to_string()),
3 => lattice_id = Some(d.str()?.to_string()),
4 => link_name = Some(d.str()?.to_string()),
5 => provider_ref = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"annotations" => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
"configuration" => {
configuration = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some( decode_configuration_string(d).map_err(|e| format!("decoding 'org.wasmcloud.lattice.control#ConfigurationString': {}", e))? ))
}
}
"hostId" => host_id = Some(d.str()?.to_string()),
"latticeId" => lattice_id = Some(d.str()?.to_string()),
"linkName" => link_name = Some(d.str()?.to_string()),
"providerRef" => provider_ref = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
StartProviderCommand {
annotations: annotations.unwrap(),
configuration: configuration.unwrap(),
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StartProviderCommand.host_id (#2)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StartProviderCommand.lattice_id (#3)".to_string(),
));
},
link_name: if let Some(__x) = link_name {
__x
} else {
return Err(RpcError::Deser(
"missing field StartProviderCommand.link_name (#4)".to_string(),
));
},
provider_ref: if let Some(__x) = provider_ref {
__x
} else {
return Err(RpcError::Deser(
"missing field StartProviderCommand.provider_ref (#5)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct StopActorCommand {
#[serde(rename = "actorId")]
#[serde(default)]
pub actor_id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotations: Option<AnnotationMap>,
#[serde(default)]
pub count: u16,
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_stop_actor_command<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &StopActorCommand,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(5)?;
e.str("actorId")?;
e.str(&val.actor_id)?;
if let Some(val) = val.annotations.as_ref() {
e.str("annotations")?;
encode_annotation_map(e, val)?;
} else {
e.null()?;
}
e.str("count")?;
e.u16(val.count)?;
e.str("hostId")?;
e.str(&val.host_id)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_stop_actor_command(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<StopActorCommand, RpcError> {
let __result = {
let mut actor_id: Option<String> = None;
let mut annotations: Option<Option<AnnotationMap>> = Some(None);
let mut count: Option<u16> = None;
let mut host_id: Option<String> = None;
let mut lattice_id: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct StopActorCommand, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => actor_id = Some(d.str()?.to_string()),
1 => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
2 => count = Some(d.u16()?),
3 => host_id = Some(d.str()?.to_string()),
4 => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"actorId" => actor_id = Some(d.str()?.to_string()),
"annotations" => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
"count" => count = Some(d.u16()?),
"hostId" => host_id = Some(d.str()?.to_string()),
"latticeId" => lattice_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
StopActorCommand {
actor_id: if let Some(__x) = actor_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StopActorCommand.actor_id (#0)".to_string(),
));
},
annotations: annotations.unwrap(),
count: if let Some(__x) = count {
__x
} else {
return Err(RpcError::Deser(
"missing field StopActorCommand.count (#2)".to_string(),
));
},
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StopActorCommand.host_id (#3)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StopActorCommand.lattice_id (#4)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct StopHostCommand {
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub timeout: Option<u64>,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_stop_host_command<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &StopHostCommand,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(3)?;
e.str("hostId")?;
e.str(&val.host_id)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
if let Some(val) = val.timeout.as_ref() {
e.str("timeout")?;
e.u64(*val)?;
} else {
e.null()?;
}
Ok(())
}
#[doc(hidden)]
pub fn decode_stop_host_command(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<StopHostCommand, RpcError> {
let __result = {
let mut host_id: Option<String> = None;
let mut lattice_id: Option<String> = None;
let mut timeout: Option<Option<u64>> = Some(None);
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct StopHostCommand, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => host_id = Some(d.str()?.to_string()),
1 => lattice_id = Some(d.str()?.to_string()),
2 => {
timeout = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.u64()?))
}
}
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"hostId" => host_id = Some(d.str()?.to_string()),
"latticeId" => lattice_id = Some(d.str()?.to_string()),
"timeout" => {
timeout = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(d.u64()?))
}
}
_ => d.skip()?,
}
}
}
StopHostCommand {
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StopHostCommand.host_id (#0)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StopHostCommand.lattice_id (#1)".to_string(),
));
},
timeout: timeout.unwrap(),
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct StopProviderCommand {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotations: Option<AnnotationMap>,
#[serde(rename = "contractId")]
#[serde(default)]
pub contract_id: String,
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
#[serde(rename = "linkName")]
#[serde(default)]
pub link_name: String,
#[serde(rename = "providerId")]
#[serde(default)]
pub provider_id: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_stop_provider_command<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &StopProviderCommand,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(6)?;
if let Some(val) = val.annotations.as_ref() {
e.str("annotations")?;
encode_annotation_map(e, val)?;
} else {
e.null()?;
}
e.str("contractId")?;
e.str(&val.contract_id)?;
e.str("hostId")?;
e.str(&val.host_id)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
e.str("linkName")?;
e.str(&val.link_name)?;
e.str("providerId")?;
e.str(&val.provider_id)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_stop_provider_command(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<StopProviderCommand, RpcError> {
let __result = {
let mut annotations: Option<Option<AnnotationMap>> = Some(None);
let mut contract_id: Option<String> = None;
let mut host_id: Option<String> = None;
let mut lattice_id: Option<String> = None;
let mut link_name: Option<String> = None;
let mut provider_id: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct StopProviderCommand, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
1 => contract_id = Some(d.str()?.to_string()),
2 => host_id = Some(d.str()?.to_string()),
3 => lattice_id = Some(d.str()?.to_string()),
4 => link_name = Some(d.str()?.to_string()),
5 => provider_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"annotations" => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
"contractId" => contract_id = Some(d.str()?.to_string()),
"hostId" => host_id = Some(d.str()?.to_string()),
"latticeId" => lattice_id = Some(d.str()?.to_string()),
"linkName" => link_name = Some(d.str()?.to_string()),
"providerId" => provider_id = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
StopProviderCommand {
annotations: annotations.unwrap(),
contract_id: if let Some(__x) = contract_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StopProviderCommand.contract_id (#1)".to_string(),
));
},
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StopProviderCommand.host_id (#2)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StopProviderCommand.lattice_id (#3)".to_string(),
));
},
link_name: if let Some(__x) = link_name {
__x
} else {
return Err(RpcError::Deser(
"missing field StopProviderCommand.link_name (#4)".to_string(),
));
},
provider_id: if let Some(__x) = provider_id {
__x
} else {
return Err(RpcError::Deser(
"missing field StopProviderCommand.provider_id (#5)".to_string(),
));
},
}
};
Ok(__result)
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct UpdateActorCommand {
#[serde(rename = "actorId")]
#[serde(default)]
pub actor_id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotations: Option<AnnotationMap>,
#[serde(rename = "hostId")]
#[serde(default)]
pub host_id: String,
#[serde(rename = "latticeId")]
#[serde(default)]
pub lattice_id: String,
#[serde(rename = "newActorRef")]
#[serde(default)]
pub new_actor_ref: String,
}
#[doc(hidden)]
#[allow(unused_mut)]
pub fn encode_update_actor_command<W: wasmbus_rpc::cbor::Write>(
mut e: &mut wasmbus_rpc::cbor::Encoder<W>,
val: &UpdateActorCommand,
) -> RpcResult<()>
where
<W as wasmbus_rpc::cbor::Write>::Error: std::fmt::Display,
{
e.map(5)?;
e.str("actorId")?;
e.str(&val.actor_id)?;
if let Some(val) = val.annotations.as_ref() {
e.str("annotations")?;
encode_annotation_map(e, val)?;
} else {
e.null()?;
}
e.str("hostId")?;
e.str(&val.host_id)?;
e.str("latticeId")?;
e.str(&val.lattice_id)?;
e.str("newActorRef")?;
e.str(&val.new_actor_ref)?;
Ok(())
}
#[doc(hidden)]
pub fn decode_update_actor_command(
d: &mut wasmbus_rpc::cbor::Decoder<'_>,
) -> Result<UpdateActorCommand, RpcError> {
let __result = {
let mut actor_id: Option<String> = None;
let mut annotations: Option<Option<AnnotationMap>> = Some(None);
let mut host_id: Option<String> = None;
let mut lattice_id: Option<String> = None;
let mut new_actor_ref: Option<String> = None;
let is_array = match d.datatype()? {
wasmbus_rpc::cbor::Type::Array => true,
wasmbus_rpc::cbor::Type::Map => false,
_ => {
return Err(RpcError::Deser(
"decoding struct UpdateActorCommand, expected array or map".to_string(),
))
}
};
if is_array {
let len = d.fixed_array()?;
for __i in 0..(len as usize) {
match __i {
0 => actor_id = Some(d.str()?.to_string()),
1 => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
2 => host_id = Some(d.str()?.to_string()),
3 => lattice_id = Some(d.str()?.to_string()),
4 => new_actor_ref = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
} else {
let len = d.fixed_map()?;
for __i in 0..(len as usize) {
match d.str()? {
"actorId" => actor_id = Some(d.str()?.to_string()),
"annotations" => {
annotations = if wasmbus_rpc::cbor::Type::Null == d.datatype()? {
d.skip()?;
Some(None)
} else {
Some(Some(decode_annotation_map(d).map_err(|e| {
format!(
"decoding 'org.wasmcloud.lattice.control#AnnotationMap': {}",
e
)
})?))
}
}
"hostId" => host_id = Some(d.str()?.to_string()),
"latticeId" => lattice_id = Some(d.str()?.to_string()),
"newActorRef" => new_actor_ref = Some(d.str()?.to_string()),
_ => d.skip()?,
}
}
}
UpdateActorCommand {
actor_id: if let Some(__x) = actor_id {
__x
} else {
return Err(RpcError::Deser(
"missing field UpdateActorCommand.actor_id (#0)".to_string(),
));
},
annotations: annotations.unwrap(),
host_id: if let Some(__x) = host_id {
__x
} else {
return Err(RpcError::Deser(
"missing field UpdateActorCommand.host_id (#2)".to_string(),
));
},
lattice_id: if let Some(__x) = lattice_id {
__x
} else {
return Err(RpcError::Deser(
"missing field UpdateActorCommand.lattice_id (#3)".to_string(),
));
},
new_actor_ref: if let Some(__x) = new_actor_ref {
__x
} else {
return Err(RpcError::Deser(
"missing field UpdateActorCommand.new_actor_ref (#4)".to_string(),
));
},
}
};
Ok(__result)
}
#[async_trait]
pub trait LatticeController {
fn contract_id() -> &'static str {
"wasmcloud:latticecontrol"
}
async fn auction_provider(
&self,
ctx: &Context,
arg: &ProviderAuctionRequest,
) -> RpcResult<ProviderAuctionAcks>;
async fn auction_actor(
&self,
ctx: &Context,
arg: &ActorAuctionRequest,
) -> RpcResult<ActorAuctionAcks>;
async fn get_hosts<TS: ToString + ?Sized + std::marker::Sync>(
&self,
ctx: &Context,
arg: &TS,
) -> RpcResult<Hosts>;
async fn get_host_inventory(
&self,
ctx: &Context,
arg: &GetHostInventoryRequest,
) -> RpcResult<HostInventory>;
async fn get_claims<TS: ToString + ?Sized + std::marker::Sync>(
&self,
ctx: &Context,
arg: &TS,
) -> RpcResult<GetClaimsResponse>;
async fn scale_actor(
&self,
ctx: &Context,
arg: &ScaleActorCommand,
) -> RpcResult<CtlOperationAck>;
async fn start_actor(
&self,
ctx: &Context,
arg: &StartActorCommand,
) -> RpcResult<CtlOperationAck>;
async fn advertise_link(
&self,
ctx: &Context,
arg: &AdvertiseLinkRequest,
) -> RpcResult<CtlOperationAck>;
async fn remove_link(
&self,
ctx: &Context,
arg: &RemoveLinkDefinitionRequest,
) -> RpcResult<CtlOperationAck>;
async fn get_links<TS: ToString + ?Sized + std::marker::Sync>(
&self,
ctx: &Context,
arg: &TS,
) -> RpcResult<LinkDefinitionList>;
async fn update_actor(
&self,
ctx: &Context,
arg: &UpdateActorCommand,
) -> RpcResult<CtlOperationAck>;
async fn start_provider(
&self,
ctx: &Context,
arg: &StartProviderCommand,
) -> RpcResult<CtlOperationAck>;
async fn stop_provider(
&self,
ctx: &Context,
arg: &StopProviderCommand,
) -> RpcResult<CtlOperationAck>;
async fn stop_actor(&self, ctx: &Context, arg: &StopActorCommand)
-> RpcResult<CtlOperationAck>;
async fn stop_host(&self, ctx: &Context, arg: &StopHostCommand) -> RpcResult<CtlOperationAck>;
async fn set_lattice_credentials(
&self,
ctx: &Context,
arg: &SetLatticeCredentialsRequest,
) -> RpcResult<CtlOperationAck>;
async fn set_registry_credentials(
&self,
ctx: &Context,
arg: &SetRegistryCredentialsRequest,
) -> RpcResult<()>;
}
#[doc(hidden)]
#[async_trait]
pub trait LatticeControllerReceiver: MessageDispatch + LatticeController {
async fn dispatch(&self, ctx: &Context, message: Message<'_>) -> Result<Vec<u8>, RpcError> {
match message.method {
"AuctionProvider" => {
let value: ProviderAuctionRequest = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'ProviderAuctionRequest': {}", e)))?;
let resp = LatticeController::auction_provider(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"AuctionActor" => {
let value: ActorAuctionRequest = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'ActorAuctionRequest': {}", e)))?;
let resp = LatticeController::auction_actor(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"GetHosts" => {
let value: String = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'String': {}", e)))?;
let resp = LatticeController::get_hosts(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"GetHostInventory" => {
let value: GetHostInventoryRequest = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'GetHostInventoryRequest': {}", e)))?;
let resp = LatticeController::get_host_inventory(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"GetClaims" => {
let value: String = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'String': {}", e)))?;
let resp = LatticeController::get_claims(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"ScaleActor" => {
let value: ScaleActorCommand = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'ScaleActorCommand': {}", e)))?;
let resp = LatticeController::scale_actor(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"StartActor" => {
let value: StartActorCommand = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'StartActorCommand': {}", e)))?;
let resp = LatticeController::start_actor(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"AdvertiseLink" => {
let value: AdvertiseLinkRequest = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'AdvertiseLinkRequest': {}", e)))?;
let resp = LatticeController::advertise_link(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"RemoveLink" => {
let value: RemoveLinkDefinitionRequest =
wasmbus_rpc::common::deserialize(&message.arg).map_err(|e| {
RpcError::Deser(format!("'RemoveLinkDefinitionRequest': {}", e))
})?;
let resp = LatticeController::remove_link(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"GetLinks" => {
let value: String = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'String': {}", e)))?;
let resp = LatticeController::get_links(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"UpdateActor" => {
let value: UpdateActorCommand = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'UpdateActorCommand': {}", e)))?;
let resp = LatticeController::update_actor(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"StartProvider" => {
let value: StartProviderCommand = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'StartProviderCommand': {}", e)))?;
let resp = LatticeController::start_provider(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"StopProvider" => {
let value: StopProviderCommand = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'StopProviderCommand': {}", e)))?;
let resp = LatticeController::stop_provider(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"StopActor" => {
let value: StopActorCommand = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'StopActorCommand': {}", e)))?;
let resp = LatticeController::stop_actor(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"StopHost" => {
let value: StopHostCommand = wasmbus_rpc::common::deserialize(&message.arg)
.map_err(|e| RpcError::Deser(format!("'StopHostCommand': {}", e)))?;
let resp = LatticeController::stop_host(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"SetLatticeCredentials" => {
let value: SetLatticeCredentialsRequest =
wasmbus_rpc::common::deserialize(&message.arg).map_err(|e| {
RpcError::Deser(format!("'SetLatticeCredentialsRequest': {}", e))
})?;
let resp = LatticeController::set_lattice_credentials(self, ctx, &value).await?;
let buf = wasmbus_rpc::common::serialize(&resp)?;
Ok(buf)
}
"SetRegistryCredentials" => {
let value: SetRegistryCredentialsRequest =
wasmbus_rpc::common::deserialize(&message.arg).map_err(|e| {
RpcError::Deser(format!("'SetRegistryCredentialsRequest': {}", e))
})?;
let _resp = LatticeController::set_registry_credentials(self, ctx, &value).await?;
let buf = Vec::new();
Ok(buf)
}
_ => Err(RpcError::MethodNotHandled(format!(
"LatticeController::{}",
message.method
))),
}
}
}
#[derive(Clone, Debug)]
pub struct LatticeControllerSender<T: Transport> {
transport: T,
}
impl<T: Transport> LatticeControllerSender<T> {
pub fn via(transport: T) -> Self {
Self { transport }
}
pub fn set_timeout(&self, interval: std::time::Duration) {
self.transport.set_timeout(interval);
}
}
#[cfg(target_arch = "wasm32")]
impl LatticeControllerSender<wasmbus_rpc::actor::prelude::WasmHost> {
pub fn new() -> Self {
let transport = wasmbus_rpc::actor::prelude::WasmHost::to_provider(
"wasmcloud:latticecontrol",
"default",
)
.unwrap();
Self { transport }
}
pub fn new_with_link(link_name: &str) -> wasmbus_rpc::error::RpcResult<Self> {
let transport = wasmbus_rpc::actor::prelude::WasmHost::to_provider(
"wasmcloud:latticecontrol",
link_name,
)?;
Ok(Self { transport })
}
}
#[async_trait]
impl<T: Transport + std::marker::Sync + std::marker::Send> LatticeController
for LatticeControllerSender<T>
{
#[allow(unused)]
async fn auction_provider(
&self,
ctx: &Context,
arg: &ProviderAuctionRequest,
) -> RpcResult<ProviderAuctionAcks> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.AuctionProvider",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: ProviderAuctionAcks = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': ProviderAuctionAcks", e)))?;
Ok(value)
}
#[allow(unused)]
async fn auction_actor(
&self,
ctx: &Context,
arg: &ActorAuctionRequest,
) -> RpcResult<ActorAuctionAcks> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.AuctionActor",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: ActorAuctionAcks = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': ActorAuctionAcks", e)))?;
Ok(value)
}
#[allow(unused)]
async fn get_hosts<TS: ToString + ?Sized + std::marker::Sync>(
&self,
ctx: &Context,
arg: &TS,
) -> RpcResult<Hosts> {
let buf = wasmbus_rpc::common::serialize(&arg.to_string())?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.GetHosts",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: Hosts = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': Hosts", e)))?;
Ok(value)
}
#[allow(unused)]
async fn get_host_inventory(
&self,
ctx: &Context,
arg: &GetHostInventoryRequest,
) -> RpcResult<HostInventory> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.GetHostInventory",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: HostInventory = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': HostInventory", e)))?;
Ok(value)
}
#[allow(unused)]
async fn get_claims<TS: ToString + ?Sized + std::marker::Sync>(
&self,
ctx: &Context,
arg: &TS,
) -> RpcResult<GetClaimsResponse> {
let buf = wasmbus_rpc::common::serialize(&arg.to_string())?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.GetClaims",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: GetClaimsResponse = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': GetClaimsResponse", e)))?;
Ok(value)
}
#[allow(unused)]
async fn scale_actor(
&self,
ctx: &Context,
arg: &ScaleActorCommand,
) -> RpcResult<CtlOperationAck> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.ScaleActor",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: CtlOperationAck = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': CtlOperationAck", e)))?;
Ok(value)
}
#[allow(unused)]
async fn start_actor(
&self,
ctx: &Context,
arg: &StartActorCommand,
) -> RpcResult<CtlOperationAck> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.StartActor",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: CtlOperationAck = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': CtlOperationAck", e)))?;
Ok(value)
}
#[allow(unused)]
async fn advertise_link(
&self,
ctx: &Context,
arg: &AdvertiseLinkRequest,
) -> RpcResult<CtlOperationAck> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.AdvertiseLink",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: CtlOperationAck = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': CtlOperationAck", e)))?;
Ok(value)
}
#[allow(unused)]
async fn remove_link(
&self,
ctx: &Context,
arg: &RemoveLinkDefinitionRequest,
) -> RpcResult<CtlOperationAck> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.RemoveLink",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: CtlOperationAck = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': CtlOperationAck", e)))?;
Ok(value)
}
#[allow(unused)]
async fn get_links<TS: ToString + ?Sized + std::marker::Sync>(
&self,
ctx: &Context,
arg: &TS,
) -> RpcResult<LinkDefinitionList> {
let buf = wasmbus_rpc::common::serialize(&arg.to_string())?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.GetLinks",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: LinkDefinitionList = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': LinkDefinitionList", e)))?;
Ok(value)
}
#[allow(unused)]
async fn update_actor(
&self,
ctx: &Context,
arg: &UpdateActorCommand,
) -> RpcResult<CtlOperationAck> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.UpdateActor",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: CtlOperationAck = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': CtlOperationAck", e)))?;
Ok(value)
}
#[allow(unused)]
async fn start_provider(
&self,
ctx: &Context,
arg: &StartProviderCommand,
) -> RpcResult<CtlOperationAck> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.StartProvider",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: CtlOperationAck = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': CtlOperationAck", e)))?;
Ok(value)
}
#[allow(unused)]
async fn stop_provider(
&self,
ctx: &Context,
arg: &StopProviderCommand,
) -> RpcResult<CtlOperationAck> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.StopProvider",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: CtlOperationAck = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': CtlOperationAck", e)))?;
Ok(value)
}
#[allow(unused)]
async fn stop_actor(
&self,
ctx: &Context,
arg: &StopActorCommand,
) -> RpcResult<CtlOperationAck> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.StopActor",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: CtlOperationAck = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': CtlOperationAck", e)))?;
Ok(value)
}
#[allow(unused)]
async fn stop_host(&self, ctx: &Context, arg: &StopHostCommand) -> RpcResult<CtlOperationAck> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.StopHost",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: CtlOperationAck = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': CtlOperationAck", e)))?;
Ok(value)
}
#[allow(unused)]
async fn set_lattice_credentials(
&self,
ctx: &Context,
arg: &SetLatticeCredentialsRequest,
) -> RpcResult<CtlOperationAck> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.SetLatticeCredentials",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
let value: CtlOperationAck = wasmbus_rpc::common::deserialize(&resp)
.map_err(|e| RpcError::Deser(format!("'{}': CtlOperationAck", e)))?;
Ok(value)
}
#[allow(unused)]
async fn set_registry_credentials(
&self,
ctx: &Context,
arg: &SetRegistryCredentialsRequest,
) -> RpcResult<()> {
let buf = wasmbus_rpc::common::serialize(arg)?;
let resp = self
.transport
.send(
ctx,
Message {
method: "LatticeController.SetRegistryCredentials",
arg: Cow::Borrowed(&buf),
},
None,
)
.await?;
Ok(())
}
}