Attributes:
- fileencrypt
- encrypt Data encryption method
- decrypt Data decryption method
- The above encryption and decryption methods must be set at the same time, otherwise encryption and decryption will not be performed.
- #[file
encrypt(encrypt="TestEncryptTool::encrypt",decrypt="TestEncryptTool::decrypt")]
dumpfilename
- Custom dump file name
- If not set ,the default dump file name is the full name of the current Struct.
- For example, the default dump file name corresponding to serde2file::test::TestData is serde2file-test-TestData.json
- #[dumpfilename = "test_data.json"]
encryptextraargtype
- Define additional encryption and decryption parameter types
- Used to pass custom parameters to encryption or decryption functions
- #[encryptextraarg
type = "&'static str"]
属性
- fileencrypt
- encrypt 数据加密方法
- decrypt 数据解密方法
- 以上加密和解密方法必须同时设置,否则不进行加解密。
- #[file
encrypt(encrypt="TestEncryptTool::encrypt",decrypt="TestEncryptTool::decrypt")]
dumpfilename
- 设置自定义的转储文件名称
- 自定义转储文件名称
- 默认为当前Struct的完整名称,
- 如serde2file::test::TestData对应的缺省转储文件名称为serde2file-test-TestData.json
- #[dumpfilename = "test_data.json"]
encryptextraargtype
- 定义额外的加解密参数类型
- 用于向加密或解密函数传递自定义参数使用
- #[encryptextraarg
type = "&'static str"]
Examples/例子
```rust
use serde2filemacroderive::Serde2File;
[allow(dead_code)]
[derive(Serialize, Deserialize, Serde2File)]
[file_encrypt(encrypt=TestEncryptTool::encrypt,decrypt=TestEncryptTool::decrypt)]
[encryptextraarg_type = "&'static str"]
[dumpfilename = "test_data"]
struct TestData{
id:String,
name:String
}
```