pub struct AstSlicer { /* private fields */ }Expand description
Condenses source code to an outline.
§Example
use boundgraph_slice::{AstSlicer, MemoryStore, Raw, Slicer};
let source = r#"
pub fn parse_header(input: &[u8]) -> Result<Header, Error> {
let mut cursor = 0;
// ... forty more lines ...
Ok(Header::default())
}
"#;
let raw = Raw::new(source).hinting("src/parse.rs");
let condensate = tokio::runtime::Builder::new_current_thread()
.build()?
.block_on(AstSlicer::new().condense(&raw, 300, &MemoryStore::new()))?;
// The signature survived; the body did not.
let rendered = format!("{:?}", condensate.payload);
assert!(rendered.contains("parse_header"));Implementations§
Source§impl AstSlicer
impl AstSlicer
Sourcepub fn relevant_to<S: Into<String>>(
self,
terms: impl IntoIterator<Item = S>,
) -> Self
pub fn relevant_to<S: Into<String>>( self, terms: impl IntoIterator<Item = S>, ) -> Self
Prefer declarations mentioning any of these terms.
The runtime supplies them from the work order’s intent — see the module documentation for why they arrive here rather than through the trait.
Trait Implementations§
Source§impl Slicer for AstSlicer
impl Slicer for AstSlicer
Source§fn slice<'life0, 'life1, 'async_trait>(
&'life0 self,
raw: &'life1 Raw,
cap: usize,
) -> Pin<Box<dyn Future<Output = Result<Slice, SliceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn slice<'life0, 'life1, 'async_trait>(
&'life0 self,
raw: &'life1 Raw,
cap: usize,
) -> Pin<Box<dyn Future<Output = Result<Slice, SliceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Produce the summary. The part an implementation writes. Read more
Source§fn counter(&self) -> &dyn TokenCount
fn counter(&self) -> &dyn TokenCount
How this slicer counts tokens. Read more
Source§fn minimum_cap(&self) -> usize
fn minimum_cap(&self) -> usize
The least a summary from this slicer can cost. Read more
Source§fn condense<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
raw: &'life1 Raw,
cap: usize,
store: &'life2 dyn Store,
) -> Pin<Box<dyn Future<Output = Result<Condensate, SliceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn condense<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
raw: &'life1 Raw,
cap: usize,
store: &'life2 dyn Store,
) -> Pin<Box<dyn Future<Output = Result<Condensate, SliceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Preserve the original, slice it, and check the result fits. Read more
Auto Trait Implementations§
impl Freeze for AstSlicer
impl RefUnwindSafe for AstSlicer
impl Send for AstSlicer
impl Sync for AstSlicer
impl Unpin for AstSlicer
impl UnsafeUnpin for AstSlicer
impl UnwindSafe for AstSlicer
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