Fix SSHSource trait bound error documentation and examples #53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses the trait bound error
[u8]: SSHSource<'_>is not satisfied that occurs when attempting to useFlashConfig::dec()directly with raw byte slices.Problem
The
SSHSourcetrait in the sunset crate is only implemented for the internalDecodeBytes<'de>struct, not for raw[u8]or&mut [u8]types. When developers try to callFlashConfig::dec()directly:The error occurs because the trait system cannot find an implementation of
SSHSourcefor the slice type.Solution
The correct approach is to use the public API
sshwire::read_ssh(), which internally creates the properDecodeBytesstruct that implementsSSHSource:Changes Made
parse_flash_config_from_buffer()function demonstrating the correct usage patternKey Insight
The sunset crate's
sshwire::read_ssh()function is the intended public interface for decoding SSH wire format data. It handles the creation of the internalDecodeBytesstruct and proper error handling, while direct calls to.dec()methods bypass these protections and can lead to type system errors.This fix ensures developers use the proper sunset crate API patterns and avoid low-level trait bound issues.
Created from VS Code via the GitHub Pull Request extension.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.