pub enum SourceInput<'a> {
Path(&'a str),
Source {
code: &'a str,
language: &'a str,
},
}Expand description
Input that can be either a file path or source code string.
This enum provides flexibility for analysis functions, allowing them to accept either a file path (which will be read and language-detected) or source code directly with an explicit language hint.
§Examples
use go_brrr::SourceInput;
// From a file path
let from_file = SourceInput::Path("./src/main.py");
// From source code with language hint
let from_source = SourceInput::Source {
code: "def hello(): return 'world'",
language: "python",
};Variants§
Path(&'a str)
Path to a source file (language auto-detected from extension).
Source
Source code string with explicit language hint.
Implementations§
Source§impl<'a> SourceInput<'a>
impl<'a> SourceInput<'a>
Sourcepub fn resolve(
&self,
) -> Result<(Vec<u8>, &'static dyn Language, Option<&'a str>)>
pub fn resolve( &self, ) -> Result<(Vec<u8>, &'static dyn Language, Option<&'a str>)>
Resolve input to (source_bytes, language_trait, optional_path).
For Path variant: reads file, detects language from extension.
For Source variant: uses provided code and language directly.
§Returns
A tuple of:
Vec<u8>: The source code as bytes&'static dyn Language: The language implementationOption<&'a str>: The file path ifPathvariant was used
§Errors
BrrrError::UnsupportedLanguageif language cannot be determinedBrrrError::Ioif file cannot be read (forPathvariant)
Trait Implementations§
Source§impl<'a> Clone for SourceInput<'a>
impl<'a> Clone for SourceInput<'a>
Source§fn clone(&self) -> SourceInput<'a>
fn clone(&self) -> SourceInput<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for SourceInput<'a>
impl<'a> RefUnwindSafe for SourceInput<'a>
impl<'a> Send for SourceInput<'a>
impl<'a> Sync for SourceInput<'a>
impl<'a> Unpin for SourceInput<'a>
impl<'a> UnwindSafe for SourceInput<'a>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request