pub struct ReadArgs {
pub path: String,
pub offset: Option<usize>,
pub limit: Option<usize>,
}Expand description
Arguments of Read.
Fields§
§path: StringThe file to read.
offset: Option<usize>The first line to read, from 1.
limit: Option<usize>How many lines to read.
Implementations§
Source§impl ReadArgs
impl ReadArgs
Sourcepub fn lines(self, offset: usize, limit: usize) -> Self
pub fn lines(self, offset: usize, limit: usize) -> Self
The same read, of at most limit lines from line offset (from 1).
Sourcepub fn show(&self, text: &str) -> String
pub fn show(&self, text: &str) -> String
What Read shows of text, the file’s whole text, for this read:
its lines from offset (default 1), at most limit of them (default
and most MAX_LINES) and MAX_BYTES, as show_lines shows them.
use rig_tools::ReadArgs;
let shown = ReadArgs::new("a.txt").lines(2, 1).show("one\ntwo\nthree\n");
assert_eq!(shown, "two\n[1 more lines; read on with offset 3]\n");Sourcepub fn shown(&self, text: &str) -> (String, LinesShown)
pub fn shown(&self, text: &str) -> (String, LinesShown)
Self::show, and which lines it shows: what Read publishes
in its FileRead, for code that shows a file as read would and
records what it showed.
use rig_tools::ReadArgs;
let (_, lines) = ReadArgs::new("a.txt").lines(2, 1).shown("one\ntwo\nthree\n");
assert_eq!((lines.first, lines.count, lines.total), (2, 1, 3));Trait Implementations§
Source§impl<'de> Deserialize<'de> for ReadArgs
impl<'de> Deserialize<'de> for ReadArgs
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ReadArgs
Source§impl JsonSchema for ReadArgs
impl JsonSchema for ReadArgs
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for ReadArgs
Auto Trait Implementations§
impl Freeze for ReadArgs
impl RefUnwindSafe for ReadArgs
impl Send for ReadArgs
impl Sync for ReadArgs
impl Unpin for ReadArgs
impl UnsafeUnpin for ReadArgs
impl UnwindSafe for ReadArgs
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
Compare self to
key and return true if they are equal.