Call A Function On An Object From A minijinja Template

MiniJinja 2.x

```cargo
[dependencies]
minijinja = "2.0.1"
```

use minijinja::value::{Object, Value};
use minijinja::{context, Environment, Error};
use std::fmt::Display;
use std::sync::Arc;

fn main() {
    let mut env = Environment::new();
    env.add_template("hello", "{{ alfa_value.ping() }}")
        .unwrap();
    let tmpl = env.get_template("hello").unwrap();
    let alfa = Alfa {};
    let alfa_value = Value::from_object(alfa);
    println!(
        "{}",
        tmpl.render(context!(alfa_value => alfa_value)).unwrap()
    );
}

#[derive(Debug)]
pub struct Alfa {}

impl Object for Alfa {
    fn call_method(
       self: &Arc<Alfa>,
        _state: &minijinja::State,
        name: &str,
        _args: &[Value],
    ) -> Result<Value, Error> {
        match name {
            // NOTE: May need to do: 
            // Value::from_serializable. 
            // TODO: Look into that
            "ping" => Ok(Value::from(self.ping())),
            _ => {
                // TODO: make this an error possibly
                Ok(Value::from(""))
            }
        }
    }
}

impl Display for Alfa {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "THIS IS ALFA DISPLAY DEFAULT FORMAT")
    }
}

impl Alfa {
    fn ping(&self) -> String {
        "One ping only".to_string()
    }
}
TODO: Show Results Output

MiniJinja 1.x

[package]
name = "minijinji_object_method_call"
version = "0.1.0"
edition = "2021"

[dependencies]
minijinja = "1.0.7"
src/main.rs
use minijinja::value::{Object, Value};
use minijinja::{context, Environment, Error};
use std::fmt::Display;

fn main() {
    let mut env = Environment::new();
    env.add_template("hello", "{{ alfa_value.ping() }}")
        .unwrap();
    let tmpl = env.get_template("hello").unwrap();
    let alfa = Alfa {};
    let alfa_value = Value::from_object(alfa);
    println!(
        "{}",
        tmpl.render(context!(alfa_value => alfa_value)).unwrap()
    );
}

#[derive(Debug)]
pub struct Alfa {}

impl Object for Alfa {
    fn call_method(
        &self,
        _state: &minijinja::State,
        name: &str,
        _args: &[Value],
    ) -> Result<Value, Error> {
        match name {
            // NOTE: May need to do: 
            // Value::from_serializable. 
            // TODO: Look into that
            "ping" => Ok(Value::from(self.ping())),
            _ => {
                // TODO: make this an error possibly
                Ok(Value::from(""))
            }
        }
    }
}

impl Display for Alfa {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "THIS IS ALFA DISPLAY DEFAULT FORMAT")
    }
}

impl Alfa {
    fn ping(&self) -> String {
        "One ping only".to_string()
    }
}
~ fin ~

References