[][src]Struct mongodb::cursor::Cursor

pub struct Cursor { /* fields omitted */ }

Maintains a connection to the server and lazily returns documents from a query.

Methods

impl Cursor[src]

pub fn command_cursor(
    client: Client,
    db: &str,
    doc: Document,
    cmd_type: CommandType,
    read_pref: ReadPreference
) -> Result<Cursor>
[src]

Construcs a new Cursor for a database command.

Arguments

client - Client making the request. db - Which database the command is being sent to. doc - Specifies the command that is being run. cmd_type - The type of command, which will be used for monitoring events. read_pref - The read preference for the query.

Return value

Returns the newly created Cursor on success, or an Error on failure.

pub fn query(
    client: Client,
    namespace: String,
    flags: OpQueryFlags,
    query: Document,
    options: FindOptions,
    cmd_type: CommandType,
    is_cmd_cursor: bool,
    read_pref: ReadPreference
) -> Result<Cursor>
[src]

Executes a query where the batch size of the returned cursor is specified.

Arguments

client - The client to read from. namespace - The namespace to read and write from. flags - Bit vector of query options. query - Document describing the query to make. options - Options for the query. cmd_type - The type of command, which will be used for monitoring events. is_cmd_cursor - Whether or not the Cursor is for a database command. read_pref - The read preference for the query.

Return value

Returns the cursor for the query results on success, or an Error on failure.

pub fn query_with_stream(
    stream: &mut PooledStream,
    client: Client,
    namespace: String,
    flags: OpQueryFlags,
    query: Document,
    options: FindOptions,
    cmd_type: CommandType,
    is_cmd_cursor: bool,
    read_pref: Option<ReadPreference>
) -> Result<Cursor>
[src]

pub fn next_n(&mut self, n: usize) -> Result<Vec<Document>>[src]

Attempts to read a specified number of BSON documents from the cursor.

Arguments

n - The number of documents to read.

Return value

Returns a vector containing the BSON documents that were read.

pub fn next_batch(&mut self) -> Result<Vec<Document>>[src]

Deprecated since 0.2.8:

this method uses 20 as the default batch size instead of letting the server decide; using drain_current_batch is recommended instead

Return value

Returns a vector containing the BSON documents that were read.

pub fn drain_current_batch(&mut self) -> Result<Vec<Document>>[src]

Attempts to read a batch of BSON documents from the cursor.

Return value

Returns a vector containing the BSON documents that were read.

pub fn has_next(&mut self) -> Result<bool>[src]

Checks whether there are any more documents for the cursor to return.

Return value

Returns true if the cursor is not yet exhausted, or false if it is.

Trait Implementations

impl Iterator for Cursor[src]

type Item = Result<Document>

The type of the elements being iterated over.

fn next(&mut self) -> Option<Result<Document>>[src]

Attempts to read a BSON document from the cursor.

Return value

Returns a BSON document if there is another one to return; None if there are no more documents to return; or an Error if the request for another document fails.

impl Debug for Cursor[src]

Auto Trait Implementations

impl Unpin for Cursor

impl Sync for Cursor

impl Send for Cursor

impl UnwindSafe for Cursor

impl RefUnwindSafe for Cursor

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<I> IteratorRandom for I where
    I: Iterator
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<I> IteratorRandom for I where
    I: Iterator
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self