pub struct StderrExcerpt { /* private fields */ }Expand description
What a failed server startup wrote to stderr, bounded and sanitized.
Holds the first and last bytes of the output (or all of it when short), so both the opening banner and the final error survive.
§Sanitizing
Control characters other than newline and tab are dropped, as are characters that forge or reorder text in logs and terminals: the Unicode line and paragraph separators, bidirectional controls and zero-width characters.
§Redaction
Values that look secret are replaced with [redacted:NAME] before the text
leaves mcpls. A value counts as secret (and must be at least 8 bytes) when
it is:
- an environment variable value, from the server’s configured
envor mcpls’s own environment, whose name containsTOKEN,KEY,SECRET,PASSW,CREDorAUTH(case-insensitive); - the value of a
--flag=valueor--flag valueargument whose flag name matches the same patterns; - a string under a matching key of
initialization_options.
Other values, such as RUSTUP_TOOLCHAIN, stay visible so the cause of a
failure can still be read. Matching is by exact value: encoded forms (URL,
base64, JSON-escaped) are not found. A secret cut by the head/tail elision
is hidden only for the fragment of at least 4 bytes on either side of the
cut. Put secrets in a name-matching env entry rather than in other
places.
Display renders one line: trimmed non-empty lines joined with |,
with ... between head and tail when elided. The raw multi-line text is
available through Self::head and Self::tail.
§Examples
use mcpls_core::Error;
use mcpls_core::error::InitPhase;
fn server_output(err: &Error) -> Option<String> {
match err {
Error::LspInitFailed { stderr: Some(stderr), .. }
| Error::ServerExitedDuringInit { stderr: Some(stderr), .. } => {
Some(stderr.to_string())
}
_ => None,
}
}
let err = Error::LspInitFailed {
phase: InitPhase::Initialize,
cause: Box::new(Error::ServerTerminated),
hint: None,
stderr: None,
};
assert_eq!(server_output(&err), None);Implementations§
Source§impl StderrExcerpt
impl StderrExcerpt
Trait Implementations§
Source§impl Clone for StderrExcerpt
impl Clone for StderrExcerpt
Source§impl Debug for StderrExcerpt
impl Debug for StderrExcerpt
Source§impl Display for StderrExcerpt
impl Display for StderrExcerpt
impl Eq for StderrExcerpt
Source§impl PartialEq for StderrExcerpt
impl PartialEq for StderrExcerpt
impl StructuralPartialEq for StderrExcerpt
Auto Trait Implementations§
impl Freeze for StderrExcerpt
impl RefUnwindSafe for StderrExcerpt
impl Send for StderrExcerpt
impl Sync for StderrExcerpt
impl Unpin for StderrExcerpt
impl UnsafeUnpin for StderrExcerpt
impl UnwindSafe for StderrExcerpt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.