Skip to main content

webui_handler/plugin/
fast.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT license.
3
4//! Deprecated FAST hydration plugin compatibility shim.
5//!
6//! FAST hydration implementations live in `fast_v2` and `fast_v3`. This module
7//! keeps the original `plugin::fast` public path available without containing
8//! hydration implementation logic.
9
10pub use super::fast_v2::FastV2HydrationPlugin;
11
12/// Deprecated compatibility alias for the legacy `fast` handler plugin.
13///
14/// Use [`FastV2HydrationPlugin`] for explicit FAST 2 compatibility. FAST 3
15/// marker output lives in [`super::fast_v3::FastV3HydrationPlugin`].
16#[deprecated(
17    since = "0.0.11",
18    note = "use plugin::fast_v2::FastV2HydrationPlugin for FAST 2 compatibility or plugin::fast_v3::FastV3HydrationPlugin for FAST 3"
19)]
20pub type FastHydrationPlugin = super::fast_v2::FastV2HydrationPlugin;
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25    use crate::plugin::HandlerPlugin;
26    use crate::{ResponseWriter, Result};
27
28    struct TestWriter {
29        output: String,
30    }
31
32    impl TestWriter {
33        fn new() -> Self {
34            Self {
35                output: String::new(),
36            }
37        }
38    }
39
40    impl ResponseWriter for TestWriter {
41        fn write(&mut self, content: &str) -> Result<()> {
42            self.output.push_str(content);
43            Ok(())
44        }
45
46        fn end(&mut self) -> Result<()> {
47            Ok(())
48        }
49    }
50
51    #[test]
52    #[allow(deprecated)]
53    fn test_fast_alias_uses_v2_markers() {
54        let mut plugin = FastHydrationPlugin::new();
55        plugin.push_scope();
56        let mut writer = TestWriter::new();
57        assert!(plugin.on_binding_start("userName", &mut writer).is_ok());
58        assert_eq!(writer.output, "<!--fe-b$$start$$0$$userName$$fe-b-->");
59    }
60}