1Type::Tiny::XS(3) User Contributed Perl Documentation Type::Tiny::XS(3)
2
3
4
6 Type::Tiny::XS - provides an XS boost for some of Type::Tiny's built-in
7 type constraints
8
10 use Types::Standard qw(Int);
11
13 This module is optionally used by Type::Tiny 0.045_03 and above to
14 provide faster, C-based implementations of some type constraints.
15 (This package has only core dependencies, and does not depend on
16 Type::Tiny, so other data validation frameworks might also consider
17 using it!)
18
19 Only the following three functions should be considered part of the
20 supported API:
21
22 Type::Tiny::XS::get_coderef_for($type)
23 Given a supported type constraint name, such as "Int", returns a
24 coderef that can be used to validate a parameter against this
25 constraint.
26
27 Returns undef if this module cannot provide a suitable coderef.
28
29 Type::Tiny::XS::get_subname_for($type)
30 Like "get_coderef_for" but returns the name of such a sub as a
31 string.
32
33 Returns undef if this module cannot provide a suitable sub name.
34
35 Type::Tiny::XS::is_known($coderef)
36 Returns true if the coderef was provided by Type::Tiny::XS.
37
38 In addition to the above functions, the subs returned by
39 "get_coderef_for" and "get_subname_for" are considered part of the
40 "supported API", but only for the lifetime of the Perl process that
41 returned them.
42
43 To clarify, if you call get_subname_for("ArrayRef[Int]") in a script,
44 this will return the name of a sub. That sub (which can be used to
45 validate arrayrefs of integers) is now considered part of the supported
46 API of Type::Tiny::XS until the script finishes running. Next time the
47 script runs, there is no guarantee that the sub will continue to exist,
48 or continue to do the same thing.
49
51 Please report any bugs to
52 <http://rt.cpan.org/Dist/Display.html?Queue=Type-Tiny-XS>.
53
55 Type::Tiny, Types::Standard.
56
58 Toby Inkster <tobyink@cpan.org> forked all this from
59 Mouse::Util::TypeConstraints.
60
61 ArrayLike, HashLike, CodeLike, and StringLike constraints based on code
62 by ikegami on StackOverflow.
63
64 <https://stackoverflow.com/a/64019481/1990570>.
65
67 This software is copyright (c) 2014, 2018-2020 by Toby Inkster.
68
69 This is free software; you can redistribute it and/or modify it under
70 the same terms as the Perl 5 programming language system itself.
71
73 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
74 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
75 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
76
77
78
79perl v5.38.0 2023-07-21 Type::Tiny::XS(3)