pub fn BaseFunction_new<A, B, F>(function: F) -> impl BaseFunction<A, B>Expand description
A BaseFunction that calls function, standing in for a Java lambda
implementing KafkaFuture.BaseFunction. A method Java adds later as an
overload of apply gets its own factory, BaseFunction_with_<parameter>.
BaseFunction is nested in KafkaFuture, so its factory lives in this
module with the interface’s name as a prefix. A is a
parameter of this function, not of the caller’s, so the closure’s
parameter type must be written out:
use confluent_kafka::common::kafka_future::{self, BaseFunction};
let len = kafka_future::BaseFunction_new(|s: String| Ok(s.len()));
assert_eq!(len.apply("four".to_string()).unwrap(), 4);§Arguments
function- the body ofapply
§Returns
A BaseFunction whose apply calls function.