pub struct Blob { /* private fields */ }Expand description
Binary blob.
Can be used to read and write to a blob. Reads and writes are buffered.
Created by Connection::open_blob.
§Example
use futures::AsyncWriteExt;
let id = conn.insert("INSERT INTO my_table (column) VALUES (?);",
asqlite::params!(asqlite::ZeroBlob(4096))).await?;
let mut blob = conn.open_blob(
"main",
"my_table",
"column",
id,
asqlite::BlobOpenMode::ReadWrite,
).await?;
blob.write_all(b"example").await?;
blob.flush().await?;Implementations§
Source§impl Blob
impl Blob
Sourcepub fn poll_read(
&mut self,
cx: &mut Context<'_>,
bytes: &mut [u8],
) -> Poll<Result<usize>>
pub fn poll_read( &mut self, cx: &mut Context<'_>, bytes: &mut [u8], ) -> Poll<Result<usize>>
Read some bytes into bytes.
See also: read.
Sourcepub fn poll_write(
&mut self,
cx: &mut Context<'_>,
bytes: &[u8],
) -> Poll<Result<usize>>
pub fn poll_write( &mut self, cx: &mut Context<'_>, bytes: &[u8], ) -> Poll<Result<usize>>
Write some bytes into buffer.
See also: write.
Sourcepub fn poll_flush(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>>
pub fn poll_flush(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>>
Flush written bytes to the database.
See also: flush.
Sourcepub fn poll_fill_buf(&mut self, cx: &mut Context<'_>) -> Poll<Result<&[u8]>>
pub fn poll_fill_buf(&mut self, cx: &mut Context<'_>) -> Poll<Result<&[u8]>>
Read the content of the internal buffer, filling it if empty.
See also: fill_buf.
Sourcepub fn consume(&mut self, bytes: usize)
pub fn consume(&mut self, bytes: usize)
Consume the internal buffer.
This function is a lower-level call that should be paired with
poll_fill_buf to work properly.
Sourcepub async fn read(&mut self, bytes: &mut [u8]) -> Result<usize>
pub async fn read(&mut self, bytes: &mut [u8]) -> Result<usize>
Read some bytes into buffer.
Returns the number of bytes read, or 0 when the EOF is reached.
Sourcepub async fn write(&mut self, bytes: &[u8]) -> Result<usize>
pub async fn write(&mut self, bytes: &[u8]) -> Result<usize>
Write some bytes into buffer.
Returns amount of bytes written.
Trait Implementations§
Source§impl AsyncBufRead for Blob
impl AsyncBufRead for Blob
Source§impl AsyncRead for Blob
impl AsyncRead for Blob
Source§impl AsyncWrite for Blob
impl AsyncWrite for Blob
Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
Attempt to write bytes from
buf into the object. Read moreSource§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Attempt to flush the object, ensuring that any buffered data reach
their destination. Read more
Auto Trait Implementations§
impl Freeze for Blob
impl !RefUnwindSafe for Blob
impl Send for Blob
impl !Sync for Blob
impl Unpin for Blob
impl !UnwindSafe for Blob
Blanket Implementations§
Source§impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
Source§fn fill_buf(&mut self) -> FillBuf<'_, Self>where
Self: Unpin,
fn fill_buf(&mut self) -> FillBuf<'_, Self>where
Self: Unpin,
Returns the contents of the internal buffer, filling it with more data if empty. Read more
Source§fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntilFuture<'a, Self>where
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntilFuture<'a, Self>where
Self: Unpin,
Source§fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self>where
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self>where
Self: Unpin,
Reads all bytes and appends them into
buf until a newline (the 0xA byte) or EOF is found. Read moreSource§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
Reads some bytes from the byte stream. Read more
Source§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
Source§fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8>,
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8>,
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
Source§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
Source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
Reads the exact number of bytes required to fill
buf. Read moreSource§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
Creates an adapter which will read at most
limit bytes from it. Read moreSource§impl<S> AsyncSeekExt for S
impl<S> AsyncSeekExt for S
Source§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
Source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>where
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>where
Self: Unpin,
Writes some bytes into the byte stream. Read more
Source§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectoredFuture<'a, Self>where
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectoredFuture<'a, Self>where
Self: Unpin,
Source§fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>where
Self: Unpin,
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>where
Self: Unpin,
Writes an entire buffer into the byte stream. Read more
Source§fn flush(&mut self) -> FlushFuture<'_, Self>where
Self: Unpin,
fn flush(&mut self) -> FlushFuture<'_, Self>where
Self: Unpin,
Flushes the stream to ensure that all buffered contents reach their destination. Read more
Source§fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a>>
fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a>>
Boxes the writer and changes its type to
dyn AsyncWrite + Send + 'a. Read moreSource§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