///|
/// Creates a policy tuned for CI logs.
///
/// It removes presentation effects, preserves line structure, and uses a
/// conservative sequence-size limit.
pub fn Policy::ci() -> Policy {
{
allow_sgr: false,
allow_hyperlinks: false,
allow_newline: true,
allow_tab: true,
max_sequence_length: 2048,
}
}
///|
/// Creates a policy tuned for untrusted AI Agent tool output.
pub fn Policy::agent() -> Policy {
{
allow_sgr: false,
allow_hyperlinks: false,
allow_newline: true,
allow_tab: true,
max_sequence_length: 1024,
}
}
///|
/// Creates a policy for canonical single-line archive records.
pub fn Policy::single_line_archive() -> Policy {
{
allow_sgr: false,
allow_hyperlinks: false,
allow_newline: false,
allow_tab: false,
max_sequence_length: 4096,
}
}
///|
pub fn Policy::allows_sgr(self : Policy) -> Bool {
self.allow_sgr
}
///|
pub fn Policy::allows_hyperlinks(self : Policy) -> Bool {
self.allow_hyperlinks
}
///|
pub fn Policy::allows_newline(self : Policy) -> Bool {
self.allow_newline
}
///|
pub fn Policy::allows_tab(self : Policy) -> Bool {
self.allow_tab
}
///|
pub fn Policy::sequence_limit(self : Policy) -> Int {
self.max_sequence_length
}
///|
/// Returns a copy with SGR styling enabled or disabled.
pub fn Policy::with_sgr(self : Policy, allowed : Bool) -> Policy {
{
allow_sgr: allowed,
allow_hyperlinks: self.allow_hyperlinks,
allow_newline: self.allow_newline,
allow_tab: self.allow_tab,
max_sequence_length: self.max_sequence_length,
}
}
///|
/// Returns a copy with OSC 8 hyperlinks enabled or disabled.
pub fn Policy::with_hyperlinks(self : Policy, allowed : Bool) -> Policy {
{
allow_sgr: self.allow_sgr,
allow_hyperlinks: allowed,
allow_newline: self.allow_newline,
allow_tab: self.allow_tab,
max_sequence_length: self.max_sequence_length,
}
}
///|
/// Returns a copy with newline preservation enabled or disabled.
pub fn Policy::with_newline(self : Policy, allowed : Bool) -> Policy {
{
allow_sgr: self.allow_sgr,
allow_hyperlinks: self.allow_hyperlinks,
allow_newline: allowed,
allow_tab: self.allow_tab,
max_sequence_length: self.max_sequence_length,
}
}
///|
/// Returns a copy with tab preservation enabled or disabled.
pub fn Policy::with_tab(self : Policy, allowed : Bool) -> Policy {
{
allow_sgr: self.allow_sgr,
allow_hyperlinks: self.allow_hyperlinks,
allow_newline: self.allow_newline,
allow_tab: allowed,
max_sequence_length: self.max_sequence_length,
}
}
///|
/// Returns a copy with a new maximum control-sequence length.
pub fn Policy::with_sequence_limit(self : Policy, limit : Int) -> Policy {
{
allow_sgr: self.allow_sgr,
allow_hyperlinks: self.allow_hyperlinks,
allow_newline: self.allow_newline,
allow_tab: self.allow_tab,
max_sequence_length: if limit < 2 {
2
} else {
limit
},
}
}
///|
/// Returns a stable short description suitable for diagnostics.
pub fn Policy::description(self : Policy) -> String {
"Policy(sgr=\{self.allow_sgr}, hyperlinks=\{self.allow_hyperlinks}, newline=\{self.allow_newline}, tab=\{self.allow_tab}, sequence_limit=\{self.max_sequence_length})"
}