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 std::sync::Arc;
21
22use cidr::{Ipv4ToCidr, Ipv6ToCidr};
23use ipv4::{Ipv4NumToString, Ipv4StringToNum};
24use ipv6::{Ipv6NumToString, Ipv6StringToNum};
25use range::{Ipv4InRange, Ipv6InRange};
26
27use crate::function_registry::FunctionRegistry;
28
29pub(crate) struct IpFunctions;
30
31impl IpFunctions {
32    pub fn register(registry: &FunctionRegistry) {
33        // Register IPv4 functions
34        registry.register(Arc::new(Ipv4NumToString));
35        registry.register(Arc::new(Ipv4StringToNum));
36        registry.register(Arc::new(Ipv4ToCidr));
37        registry.register(Arc::new(Ipv4InRange));
38
39        // Register IPv6 functions
40        registry.register(Arc::new(Ipv6NumToString));
41        registry.register(Arc::new(Ipv6StringToNum));
42        registry.register(Arc::new(Ipv6ToCidr));
43        registry.register(Arc::new(Ipv6InRange));
44    }
45}