pub fn publish<T: PublishKind>(
topic: impl AsRef<str>,
value: T,
) -> Result<(), PublishError<<<T as PublishKind>::Encoding as Encode>::Error>>Expand description
Publish a message to a topic in the cache this Function is running within.
Examples:
String:
use momento_functions_host::topics::PublishError;
fn f() -> Result<(), PublishError<&'static str>> {
topics::publish("my_topic", "hello there")?;Bytes:
use momento_functions_host::topics::PublishError;
fn f() -> Result<(), PublishError<&'static str>> {
topics::publish("my_topic", b"hello there".to_vec())?;Json:
use momento_functions_host::encoding::Json;///
use momento_functions_host::topics::PublishError;
#[derive(serde::Serialize)]
struct MyStruct {
hello: String
}
topics::publish("my_topic", Json(MyStruct{ hello: "hello".to_string() }))?;