sass_alt/values/
StringSassValue.rs

1// This file is part of sass-alt. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/sass-alt/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2017 The developers of sass-alt. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/sass-alt/master/COPYRIGHT.
3
4
5/// A Sass_Value typed as a known string.
6#[derive(Debug, Copy, Clone)]
7pub struct StringSassValue<'a>
8{
9	reference: &'a SassValue,
10}
11
12impl<'a> StringSassValue<'a>
13{
14	/// Get string value.
15	#[inline(always)]
16	pub fn value(&self) -> &'a CStr
17	{
18		unsafe
19		{
20			let value = sass_string_get_value(self.reference.0 as *const _);
21			CStr::from_ptr(value)
22		}
23	}
24	
25	/// Set string value.
26	#[inline(always)]
27	pub fn set_value(&self, value: &CStr)
28	{
29		unsafe { sass_string_set_value(self.reference.0, sass_copy_c_string(value.as_ptr()) ) }
30	}
31	
32	/// Get whether this is a quoted string.
33	#[inline(always)]
34	pub fn is_quoted(&self) -> bool
35	{
36		unsafe { sass_string_is_quoted(self.reference.0 as *const _) }
37	}
38	
39	/// Set whether this is a quoted string.
40	#[inline(always)]
41	pub fn set_is_quoted(&self, is_quoted: bool)
42	{
43		unsafe { sass_string_set_quoted(self.reference.0, is_quoted) }
44	}
45}