use std::rc::Rc;
use url::Url;
use crate::item::{Item, Node, Sequence, SequenceTrait};
use crate::transform::Transform;
use crate::transform::context::{Context, StaticContext};
use crate::value::Value;
use crate::xdmerror::Error;
pub fn boolean<
N: Node,
F: FnMut(&str) -> Result<(), Error>,
G: FnMut(&str) -> Result<N, Error>,
H: FnMut(&Url) -> Result<String, Error>,
>(
ctxt: &Context<N>,
stctxt: &mut StaticContext<N, F, G, H>,
b: &Transform<N>,
) -> Result<Sequence<N>, Error> {
Ok(vec![Item::Value(Rc::new(Value::from(
ctxt.dispatch(stctxt, b)?.to_bool(),
)))])
}
pub fn not<
N: Node,
F: FnMut(&str) -> Result<(), Error>,
G: FnMut(&str) -> Result<N, Error>,
H: FnMut(&Url) -> Result<String, Error>,
>(
ctxt: &Context<N>,
stctxt: &mut StaticContext<N, F, G, H>,
n: &Transform<N>,
) -> Result<Sequence<N>, Error> {
Ok(vec![Item::Value(Rc::new(Value::from(
!ctxt.dispatch(stctxt, n)?.to_bool(),
)))])
}
pub fn tr_true<N: Node>(_ctxt: &Context<N>) -> Result<Sequence<N>, Error> {
Ok(vec![Item::Value(Rc::new(Value::from(true)))])
}
pub fn tr_false<N: Node>(_ctxt: &Context<N>) -> Result<Sequence<N>, Error> {
Ok(vec![Item::Value(Rc::new(Value::from(false)))])
}