usage / 用法
```rust
[derive(Serialize, Deserialize, Serde2File)]
[serde2file(
encrypt = "TestEncryptTool::encrypt",
decrypt = "TestEncryptTool::decrypt",
crypt_arg_type = "&'static str",
dump_file_name = "test_data.json"
)]
```
Attributes / 属性 :
[serde2file(arg1=value1,...)]
- 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.
- example : #[serde2file(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
- example : #[serde2file(dumpfilename = "test_data.json")]
- cryptargtype
- Define additional encryption and decryption parameter types
- Used to pass custom parameters to encryption or decryption functions
- example : #[serde2file(cryptargtype = "&'static str")]
[serde2file(参数1=值1,...)]
- encrypt 数据加密方法
- decrypt 数据解密方法
- 以上加密和解密方法必须同时设置,否则不进行加解密。
- 例如:#[file_encrypt(encrypt="TestEncryptTool::encrypt",decrypt="TestEncryptTool::decrypt")]
- dumpfilename
- 设置自定义的转储文件名称
- 自定义转储文件名称
- 默认为当前Struct的完整名称,
- 如serde2file::test::TestData对应的缺省转储文件名称为serde2file-test-TestData.json
- 例如:#[serde2file(dumpfilename = "test_data.json")]
- cryptargtype
- 定义额外的加解密参数类型
- 用于向加密或解密函数传递自定义参数使用
- 例如:#[serde2file(cryptargtype = "&'static str")]
Examples/例子
```rust
use serde2filemacroderive::Serde2File;
[derive(Debug, Serialize, Deserialize, Default, PartialEq, Eq, Serde2File)]
[serde2file(
encrypt = "TestEncryptTool::encrypt",
decrypt = "TestEncryptTool::decrypt",
crypt_arg_type = "&'static str",
dump_file_name = "test_data.json"
)]
struct TestData {
id: String,
name: String,
}
```