Struct Writer

Source
pub struct Writer { /* private fields */ }
Expand description

Write queries for cmake-file-api.

§Example

use cmake_file_api::{query, objects};

query::Writer::default()
  .request_object::<objects::CodeModelV2>()
  .write_stateless(&build_dir)
  .expect("Failed to write query");

Implementations§

Source§

impl Writer

Source

pub fn request_object<T: Object>(&mut self) -> &mut Self

Request cmake-file-api object

Source

pub fn add_request_exact<T: Object>(&mut self, minor: u32) -> &mut Self

Request cmake-file-api object with exact version (minor version only used for stateful queries)

Source

pub fn request_all_objects(&mut self) -> &mut Self

Helper function to request all objects

Source

pub fn set_client(&mut self, client_name: &str, client_data: Value) -> &mut Self

Set client data Only used for stateful queries

§Arguments
  • client_name - Client name
  • client_data - Client data (JSON)
Source

pub fn write_stateless<P: AsRef<Path>>( &self, build_dir: P, ) -> Result<(), WriterError>

Write stateless query For every object requested, a file is created in the query folder e.g. <build_dir>/.cmake/api/v1/query/codemodel-v2

§Errors

Returns an error if the query folder could not be created Returns an error if the query file could not be written

Source

pub fn write_stateful<P: AsRef<Path>>( &self, build_dir: P, ) -> Result<(), WriterError>

Write stateful query A single <client-name>/query.json file is created in the query folder containing all requested objects and when set the client data

§Arguments
  • build_dir - Build directory
§Errors

Returns an error if the query file could not be written

Trait Implementations§

Source§

impl Default for Writer

Source§

fn default() -> Writer

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Writer

§

impl RefUnwindSafe for Writer

§

impl Send for Writer

§

impl Sync for Writer

§

impl Unpin for Writer

§

impl UnwindSafe for Writer

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.