This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

FragmentResult Pennington.TreeSitter.Fragments

Outcome of a fragment lookup: either the extracted Text or an Error message.

Properties

Error string
The failure message when unsuccessful; otherwise null.
Succeeded bool
True when extraction succeeded.
Text string
The extracted source text when successful; otherwise null.

Constructors

FragmentResult

#
public FragmentResult(string Text, string Error)

Outcome of a fragment lookup: either the extracted Text or an Error message.

Parameters

Text string
The extracted source text when successful; otherwise null.
Error string
The failure message when unsuccessful; otherwise null.

Methods

Fail

#
public static FragmentResult Fail(string error)

Creates a failed result with the given error message.

Parameters

error string

Returns

FragmentResult

Ok

#
public static FragmentResult Ok(string text)

Creates a successful result wrapping text.

Parameters

text string

Returns

FragmentResult

Pennington.TreeSitter.Fragments.FragmentResult

namespace Pennington.TreeSitter.Fragments;

/// Outcome of a fragment lookup: either the extracted Text or an Error message.
public record FragmentResult
{
    /// The failure message when unsuccessful; otherwise null.
    
public string Error { get; set; }
/// Creates a failed result with the given error message.
public static FragmentResult Fail(string error)
; /// Outcome of a fragment lookup: either the extracted Text or an Error message.
public FragmentResult(string Text, string Error)
; /// Creates a successful result wrapping text.
public static FragmentResult Ok(string text)
; /// True when extraction succeeded.
public bool Succeeded { get; }
/// The extracted source text when successful; otherwise null.
public string Text { get; set; }
}