docx_reader/documents/
toc_key.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::sync::atomic::AtomicUsize;

static TOC_KEY: AtomicUsize = AtomicUsize::new(0);

pub trait TocKeyGenerator {
	fn generate() -> String {
		use std::sync::atomic::Ordering;

		let id = TOC_KEY.load(Ordering::Relaxed);
		TOC_KEY.store(id + 1, Ordering::Relaxed);
		format!("_Toc{:08}", id)
	}
}

pub struct TocKey {}

impl TocKeyGenerator for TocKey {}