1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// =============================================================================
// Copyright (c) 2025 - 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Adapters for text and typed validation closures with dependency context.
use Arc;
use BoundValidationContext;
use DependencySpec;
use ExecutionError;
use PreparedOutcome;
use PreparedValidator;
use TextContextFnAdapter;
use TypedContextFnAdapter;
/// Prepares a text validation closure that receives its checked dependency
/// context.
///
/// The closure can report a valid input, one or more violation drafts, or an
/// execution failure. `BoundValidator` checks declared dependencies before it
/// invokes this adapter. When calling the returned `PreparedValidator`
/// directly, the closure is responsible for reading and checking its context.
///
/// Callers must keep raw rejected input out of violation drafts and execution
/// errors. Captured data must be owned and thread-safe.
///
/// # Type Parameters
///
/// - `F`: Thread-safe operation for one text input and its dependency context.
///
/// # Parameters
///
/// - `dependencies`: Static dependency slots consumed by `call`, in execution
/// order.
/// - `call`: Operation invoked with checked text and a borrowed dependency
/// context.
///
/// # Returns
///
/// A shared prepared validator that checks the target is text before invoking
/// `call` and forwards any execution errors from it unchanged. This function
/// only constructs the adapter and does not itself return an error.
/// Prepares a typed validation closure that receives its checked dependency
/// context.
///
/// The closure can report a valid input, one or more violation drafts, or an
/// execution failure. `BoundValidator` checks declared dependencies before it
/// invokes this adapter. When calling the returned `PreparedValidator`
/// directly, the closure is responsible for reading and checking its context.
///
/// Callers must keep raw rejected input out of violation drafts and execution
/// errors. Captured data must be owned and thread-safe.
///
/// # Type Parameters
///
/// - `T`: Exact input type, which must be `'static` for `TypeId`.
/// - `F`: Thread-safe operation for one typed input and its dependency context.
///
/// # Parameters
///
/// - `dependencies`: Static dependency slots consumed by `call`, in execution
/// order.
/// - `call`: Operation invoked with a checked `T` value and borrowed context.
///
/// # Returns
///
/// A shared prepared validator that checks the target has type `T` before
/// invoking `call` and forwards any execution errors from it unchanged. This
/// function only constructs the adapter and does not itself return an error.