pub struct MemoryRangeReader { /* private fields */ }Expand description
In-memory range reader for bytes already loaded into memory
This is useful when you have already fetched COG data (e.g., from a cache or network) and want to parse it without writing to disk.
§Example
use cogrs::{CogReader, MemoryRangeReader};
use std::sync::Arc;
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let bytes = std::fs::read("path/to/file.tif")?;
let reader = MemoryRangeReader::new(bytes, "cached://my-layer.tif".to_string());
let cog = CogReader::from_reader(Arc::new(reader))?;
Ok(())
}Implementations§
Source§impl MemoryRangeReader
impl MemoryRangeReader
Trait Implementations§
Source§impl RangeReader for MemoryRangeReader
impl RangeReader for MemoryRangeReader
Source§fn read_range(&self, offset: u64, length: usize) -> AnyResult<Vec<u8>>
fn read_range(&self, offset: u64, length: usize) -> AnyResult<Vec<u8>>
Read a range of bytes from the source Read more
Source§fn identifier(&self) -> &str
fn identifier(&self) -> &str
Get a human-readable identifier for this source (for logging/errors)
Source§fn is_local(&self) -> bool
fn is_local(&self) -> bool
Check if this is a local file (fast random access) or remote (expensive reads)
Source§fn reads_inline(&self) -> bool
fn reads_inline(&self) -> bool
True when
read_range never blocks on I/O (e.g. in-memory data), so async adapters
may call it directly instead of moving it to a blocking thread.Auto Trait Implementations§
impl Freeze for MemoryRangeReader
impl RefUnwindSafe for MemoryRangeReader
impl Send for MemoryRangeReader
impl Sync for MemoryRangeReader
impl Unpin for MemoryRangeReader
impl UnsafeUnpin for MemoryRangeReader
impl UnwindSafe for MemoryRangeReader
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> 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 more