common_function/scalars/
ip.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15mod cidr;
16mod ipv4;
17mod ipv6;
18mod range;
19
20use cidr::{Ipv4ToCidr, Ipv6ToCidr};
21use ipv4::{Ipv4NumToString, Ipv4StringToNum};
22use ipv6::{Ipv6NumToString, Ipv6StringToNum};
23use range::{Ipv4InRange, Ipv6InRange};
24
25use crate::function_registry::FunctionRegistry;
26
27pub(crate) struct IpFunctions;
28
29impl IpFunctions {
30    pub fn register(registry: &FunctionRegistry) {
31        // Register IPv4 functions
32        registry.register_scalar(Ipv4NumToString);
33        registry.register_scalar(Ipv4StringToNum);
34        registry.register_scalar(Ipv4ToCidr);
35        registry.register_scalar(Ipv4InRange);
36
37        // Register IPv6 functions
38        registry.register_scalar(Ipv6NumToString);
39        registry.register_scalar(Ipv6StringToNum);
40        registry.register_scalar(Ipv6ToCidr);
41        registry.register_scalar(Ipv6InRange);
42    }
43}