Skip to main content

get_ttl_info

Function get_ttl_info 

Source
pub fn get_ttl_info(encoded: &str) -> Result<Option<TtlInfo>>
Expand description

获取编码的 TTL 信息

§参数

  • encoded - DX 编码的字符串

§返回值

如果编码包含 TTL 信息,返回 Some(TtlInfo),否则返回 None

§示例

use dxcode::{encode_with_ttl, get_ttl_info};

let encoded = encode_with_ttl(b"Hello", 3600); // 1小时有效期
if let Some(info) = get_ttl_info(&encoded).unwrap() {
    println!("创建于: {}", info.created_at);
    println!("过期: {}", info.is_expired);
}