datafusion_common/
encryption.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18// Support optional features for encryption in Parquet files.
19//! This module provides types and functions related to encryption in Parquet files.
20
21#[cfg(feature = "parquet_encryption")]
22pub use parquet::encryption::decrypt::FileDecryptionProperties;
23#[cfg(feature = "parquet_encryption")]
24pub use parquet::encryption::encrypt::FileEncryptionProperties;
25
26#[cfg(not(feature = "parquet_encryption"))]
27#[derive(Default, Debug)]
28pub struct FileDecryptionProperties;
29#[cfg(not(feature = "parquet_encryption"))]
30#[derive(Default, Debug)]
31pub struct FileEncryptionProperties;
32
33pub use crate::config::{ConfigFileDecryptionProperties, ConfigFileEncryptionProperties};
34
35#[cfg(feature = "parquet_encryption")]
36pub fn map_encryption_to_config_encryption(
37    encryption: Option<&FileEncryptionProperties>,
38) -> Option<ConfigFileEncryptionProperties> {
39    encryption.map(|fe| fe.into())
40}
41
42#[cfg(not(feature = "parquet_encryption"))]
43pub fn map_encryption_to_config_encryption(
44    _encryption: Option<&FileEncryptionProperties>,
45) -> Option<ConfigFileEncryptionProperties> {
46    None
47}
48
49#[cfg(feature = "parquet_encryption")]
50pub fn map_config_decryption_to_decryption(
51    decryption: &ConfigFileDecryptionProperties,
52) -> FileDecryptionProperties {
53    decryption.clone().into()
54}
55
56#[cfg(not(feature = "parquet_encryption"))]
57pub fn map_config_decryption_to_decryption(
58    _decryption: &ConfigFileDecryptionProperties,
59) -> FileDecryptionProperties {
60    FileDecryptionProperties {}
61}